note 113386 added to function.addslashes
| From: | DavidSpector | Date: | Fri, 04 Oct 2013 14:30:23 +0000 |
| Subject: | note 113386 added to function.addslashes | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-196466@lists.php.net to get a copy of this message | ||
If all you want to do is quote a string as you would normally do in PHP (for example, when returning
an Ajax result, inside a json string value, or when building a URL with args), don't use
addslashes (you don't want both " and ' escaped at the same time). Instead, just use
this function:
<?php
function Quote($Str) // Double-quoting only
{
$Str=str_replace('"','\"',$Str);
return '"'.$Str.'"';
} // Quote
?>
Modify this easily to get a single-quoting function.
----
Server IP: 69.147.83.199
Probable Submitter: 108.183.129.223
----
Manual Page -- http://php.net/manual/en/function.addslashes.php
Edit -- https://master.php.net/note/edit/113386
Del: integrated -- https://master.php.net/note/delete/113386/integrated
Del: useless -- https://master.php.net/note/delete/113386/useless
Del: bad code -- https://master.php.net/note/delete/113386/bad+code
Del: spam -- https://master.php.net/note/delete/113386/spam
Del: non-english -- https://master.php.net/note/delete/113386/non-english
Del: in docs -- https://master.php.net/note/delete/113386/in+docs
Del: other reasons-- https://master.php.net/note/delete/113386
Reject -- https://master.php.net/note/reject/113386
Search -- https://master.php.net/manage/user-notes.php