Re: coding special characters in html

From: Date: Sun, 17 Nov 2002 22:29:39 +0000
Subject: Re: coding special characters in html
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-124835@lists.php.net to get a copy of this message
Sure, its htmlentities(), combined (possibly) with nb2br() http://www.php.net/manual/en/function.htmlentities.php Marco On Sun, 2002-11-17 at 17:34, Børge Strand wrote: > > Hi all, > > I'm cooking tothether a tiny php html editor right now, (textarea kind > of thing). To treat the text properly I need to encode characters like > '"', '<', '>', and friends into something that > doesn't confuse the > browser. > > I got it to work with regexps, you can see a part of the decoder > below. But I believe there must be some automatic stuff in php which > does this. Anybody out there knowing about such a function? > > $pattern = "/&#34;/"; > $replacement = "\""; > $string = preg_replace($pattern ,$replacement, $string); > > By the way, do you think encoding and decoding special characters like > this may replace addslashes() and stripslashes()? The html pages will > be stored in a MySQL database. > > Also, addslashes() will reduce the chance of bad stuff being passed to > MySQL. But is there a function which stops client-side scripts in > whatever is entered by the user? > > > Regards, > > Børge > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php >

« previous php.general (#124835) next »