Need a nicer way to escape single/double quotes....

From: Date: Wed, 12 Nov 2003 21:46:23 +0000
Subject: Need a nicer way to escape single/double quotes....
Groups: php.general 
Request: Send a blank email to php-general+get-169368@lists.php.net to get a copy of this message
Hi Fellas! I haven't found a more efficient way to better escape the quote characters for the javascript right from PHP because I only get "The kid" in the javascript alert message, so I'm wondering if anyone of you know of something better than that... --snip-- <form name="Test_Form"> <? $test1 = "The kid's name is \"Bob!\""; $test1 = addslashes($test1); echo "<input type='hidden' name='htmlTest1' value='".$test1."'>"; echo "<script type='text/javascript'>"; echo " alert(document.Test_Form.htmlTest1.value);"; echo "</script>"; ?> </form> --snip-- Thanks, Scott F.

« previous php.general (#169368) next »