Reputation: 314
I'm using PHP environment and I have a problem in displaying data on form of escape characters.
example:
how could i display a double quote "
if my string data is \"
same with, how could i display a backslash \
if my string data is \\
Upvotes: 0
Views: 1678
Reputation: 10148
Everyone else has covered it and this is all documented here but for the sake of completeness I'd also suggest taking a look at the heredoc
notation which can be useful when your data is changing through several contexts (eg. PHP -> HTML/JS -> JS-Regex)
<?php
echo <<<__EOF
It's not great for PHP indentation but often helps readability \ " ' `
__EOF;
Upvotes: 0
Reputation: 943569
To remove \
characters that are used as an escape characters, use the stripslashes
function.
david@raston ~ $ cat tmp/test.php
<?php
$raw = 'double slash \\\\ escaped quote \"';
print $raw;
print "\n";
print stripslashes($raw);
?>
david@raston ~ $ php tmp/test.php
double slash \\ escaped quote \"
double slash \ escaped quote "
Upvotes: 1