I took these sentences from the PHP manual:
\'this is a simple string\',
\'Arnold once said: \"I\\\'ll be back\"\',
\'You deleted C:\\\\*.*?\',
\'You deleted
Instead of meddling with preg_replace()
, consider using var_export()
to print a "true copy" of the string:
foreach ($strings as $s) {
echo var_export($s, true), PHP_EOL;
}
Output:
'this is a simple string'
'Arnold once said: "I\'ll be back"'
'You deleted C:\\*.*?'
'You deleted C:\\*.*?'
'This will not expand: \\n a newline'
'Variables do not $expand $either'
As you can see, sentence 3 and 4 are identical to PHP.