Curriculum
Course: PHP Basic
Login

Curriculum

PHP Basic

PHP Install

0/1

PHP Casting

0/1

PHP Constants

0/1

PHP Magic Constants

0/1

PHP Operators

0/1

PHP Reference

0/276
Text lesson

Escape Characters

Escape Character

To include characters that are not allowed in a string, use an escape character.

An escape character consists of a backslash \ followed by the character you wish to insert.

For example, a double quote inside a string enclosed by double quotes is considered an illegal character.

Example

$x = “We are the so-called “Vikings” from the north.”;

To resolve this issue, use the escape character \".

Example

$x = “We are the so-called \”Vikings\” from the north.”;

Escape Characters

Other escape characters commonly used in PHP include:

Code

Result

\’

Single Quote

\”

Double Quote

\$

PHP variables

\n

New Line

\r

Carriage Return

\t

Tab

\f

Form Feed

\ooo

Octal value

\xhh

Hex value