note 32960 deleted from function.str-replace by didou

From: Date: Sat, 09 Aug 2003 22:47:44 +0000
Subject: note 32960 deleted from function.str-replace by didou
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-53766@lists.php.net to get a copy of this message
Note Submitter: kieran@lv6.net ---- Mentioned above is some advice about using str_replace to parse text to go inside javascript document.write()s, however, both seem to be wrong. 1) You don't need to escape ' inside a " in php. 2) You should do your slash escaping first so as not to double-escape slashes. Here's my code: $string=str_replace("\\", "\\\\", $string); $string=str_replace("'", "\'", $string); $string=str_replace("\"", "\\\"", $string); Hope that saves someone some confusion.

« previous php.notes (#53766) next »