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

Reply via email to