note 77139 deleted from function.addslashes by danbrown
| From: | danbrown@php.net | Date: | Mon, 24 Nov 2008 16:56:44 +0000 |
| Subject: | note 77139 deleted from function.addslashes by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-146886@lists.php.net to get a copy of this message | ||
Note Submitter: David Harris
----
If you need to make a PHP string literal, addslashes does work for this use because it escapes the
double quote mark.
This works:
$data = "whatever";
$escaped = preg_replace('{([\'\\\\])}', '\\\\$1', $data);
$literal = '\'' . $escaped . '\'';