What Are the Special Characters You Need to Escape in Single-Quoted Stings

Q

What Are the Special Characters You Need to Escape in Single-Quoted Stings? - PHP Script Tips - Understanding String Literals and Operations

✍: 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.

2007-04-20, 4605👍, 0💬