note 79309 added to function.htmlspecialchars
| From: | ish1301atgmaildooootcom at osu1 dot php dot net | Date: | Tue, 20 Nov 2007 10:56:59 +0000 |
| Subject: | note 79309 added to function.htmlspecialchars | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-132430@lists.php.net to get a copy of this message | ||
used this function for making a variable javascript compatible
<?php
function jsspecialchars( $string = '') {
$string = preg_replace("/\r*\n/","\\n",$string);
$string = preg_replace("/\//","\\\/",$string);
$string = preg_replace("/\"/","\\\"",$string);
$string = preg_replace("/'/"," ",$string);
return $string;
}
?>
hope this may help those embedding php in javascripts
----
Server IP: 219.94.145.73
Probable Submitter: 122.162.203.63
----
Manual Page -- http://www.php.net/manual/en/function.htmlspecialchars.php
Edit -- https://master.php.net/note/edit/79309
Del: integrated -- https://master.php.net/note/delete/79309/integrated
Del: useless -- https://master.php.net/note/delete/79309/useless
Del: bad code -- https://master.php.net/note/delete/79309/bad+code
Del: spam -- https://master.php.net/note/delete/79309/spam
Del: non-english -- https://master.php.net/note/delete/79309/non-english
Del: in docs -- https://master.php.net/note/delete/79309/in+docs
Del: other reasons-- https://master.php.net/note/delete/79309
Reject -- https://master.php.net/note/reject/79309
Search -- https://master.php.net/manage/user-notes.php