When using smilies, a user enters certain character into the textbox. Ex 🙂
Then PHP would search the textbox entry for those characters. If it finds them it replaces it with a <img> tag. Ex preg_replace("/\s(:))\s/i", '<img src="smilies/smile.gif">', $textbox);
There's more to it than that. Most people, like PHP builder, have a list of their smilies. And when a user clicks on one JavaScript inserts the characters into the textbox. And, replaceing the characters with <img> tags is normaly done during output. That way if a user edits their message they see the characters, not an <img> tag.