RE: [PHP] UN-Escaping text from a form submit?

From: Date: Thu, 08 Feb 2001 03:57:29 +0000
Subject: RE: [PHP] UN-Escaping text from a form submit?
Groups: php.general 
Request: Send a blank email to php-general+get-38663@lists.php.net to get a copy of this message
> The title of this book doesn't really matter to "me"! > > When I get that back, and read it from the file, it always > ends up like: > > The title of this book doesn\'t really matter to \"me\"! > > Note the addition of the escape sequences. How can I stop > this? Is there some function in PHP? Or am I goign to have > to write a character routine to strip out escape sequences? > <shudder> Very simple. If magic_quotes_gpc is on, PHP does an addslashes() on all stuff that comes in via HTTP GET, HTTP POST or a cookie. And, there's a lovely function get_magic_quotes_gpc() that tells you its status. So: if (get_magic_quotes_gpc()) { // Magic quotes is on, we don't want stuff escaped. $value = stripslashes($value); } This is handy to use in your script even if you know the way your system is set up in php.ini - if you port your script to another server that is set up differently, then it'll still work as you expect. Jason

« previous php.general (#38663) next »