Escape Sequences in Single-Quoted Strings in PHP

Q

How Many Escape Sequences Are Recognized in Single-Quoted Strings?

✍: FYIcenter.com

A

There are two special characters you need to escape in a single-quote string: the single quote (') and the back slash (\). Here is a PHP script example of single-quoted strings:

<?php 
echo 'Hello world!'; 
echo 'It\'s Friday!'; 
echo '\\ represents an operator.'; 
?>

This script will print:

Hello world!It's Friday!\ represents an operator.

 

"new line" Character in Single-Quoted Strings in PHP

Understanding PHP String Literals and Operations

Understanding PHP String Literals and Operations

⇑⇑ PHP Tutorials

2016-10-13, 1693🔥, 0💬