PHP

PHP ESCAPE CHARACTERS & SEQUENCES

(quick guide & examples)

TRYING TO ADD SINGLE QUOTES $strA = 'Foo's Bar.';   TRYING TO ADD DOUBLE QUOTES $strB = "Jon says "foo bar".";

THE PROBLEM WITH STRINGS

01

TRYING TO ADD DOLLAR SIGN $strC = "Joy says $foo bar.";   TRYING TO ADD SLASHES $strD = "D:\test\file.txt";

ESCAPE SINGLE QUOTE $strA = 'Foo\'s Bar.';   ESCAPE DOUBLE QUOTES $strB = "Jon says \"foo bar\".";

USING ESCAPE SEQUENCE

02

ESCAPE DOLLAR SIGN $strC = "Joy says \$foo bar.";   ESCAPE SLASHES $strD = "D:\\test\\file.txt";

LINE BREAK $strA = 'First\r\nSecond';   TAB $strB = "\tThird";

USING ESCAPE CHARACTERS

03