PHP Interview Questions

Escape Sequence in PHP

Backslash () is used in PHP as escaping character. Escape sequences are started with escaping character backslash ().


List of widely used escape sequences in PHP:


Print the next character as a double quote

Print the next character as a single quote

n

Print a new line character

t

Print a tab character

r

Print a carriage return 

$

Print the next character as a dollar

Escape Sequence Examples :


Here is a code example of these escape sequences in action:

<?php
    echo
“This is an “escaped double quote” string”
;
    
echoNaman’s photo”
;
    
echo “I have $100 in my pocket”
;
    
echo “This ends with a line returnn”
;
    
echo “c:\Download\myfile.txt”
;
?>


Output :
This is an “escaped double quote” string;
Naman’s photo
I have $100 in my pocket
This ends with a line return


c:Downloadmyfile.txt

Leave a Reply