Table of Contents
<h2>Escape Character</h2>
<p>To insert characters that are illegal in a string, use an escape character.
An escape character is a backslash \ followed by the character you want to insert.
An example of an illegal character is a double quote inside a string that is surrounded by double quotes:</p>
<?php
echo "We are the so-called \"Vikings\" from the north.";
?>
Result View Example
<h2>Other_escape_characters</h2>
<h4>\' Single Quote</h4>
<?php
$x = 'We are the so-called \'Vikings\' from the north.';
echo $x;
?>
<h4>\" Double Quote</h4>
<?php
$x = "We are the so-called \"Vikings\" from the north.";
echo $x;
?>
<h4>\$ PHP variables</h4>
<?php
$x = "Escape php variable name \$myvar";
echo $x;
?>
<h4>\n New Line</h4>
<pre>
<?php
$x = "Hello\nWorld";
echo $x;
?>
</pre>
<p>To preserve any whitespace or line breaks, we have wrapped the result in a PRE element</p>
<h4>\r Carriage Return</h4>
<pre>
<?php
$x = "Hello\rWorld";
echo $x;
?>
</pre>
<h4>\t Tab</h4>
<pre>
<?php
$x = "Hello\tWorld";
echo $x;
?>
</pre>
<h4>\ooo Octal value</h4>
<?php
$x = "\110\145\154\154\157";
echo $x;
?>
<h4>\xhh Hex value</h4>
<?php
$x = "\x48\x65\x6c\x6c\x6f";
echo $x;
?>
Result View Example
Document in project
You can Download PDF file.