Syntax: Single quoted

echo 'this is a simple string';

echo 'You can also have embedded newlines in
strings this way as it is
okay to do';

// Outputs: Arnold once said: "I'll be back"
echo 'Arnold once said: "I\'ll be back"';

// Outputs: You deleted C:\*.*?
echo 'You deleted C:\\*.*?';

// Outputs: You deleted C:\*.*?
echo 'You deleted C:\*.*?';

// Outputs: This will not expand: \n a newline
echo 'This will not expand: \n a newline';

// Outputs: Variables do not $expand $either
echo 'Variables do not $expand $either';

The simplest way to specify a string is to enclose it in single quotes (the character ').

Unlike the double-quoted and heredoc syntaxes, variables and escape sequences for special characters will not be expanded when they occur in single quoted strings.

To specify a literal single quote, escape it with a backslash (\).
To specify a literal backslash, double it (\\).
Other escape sequences you might be used to, such as \r or \n, will be output literally as specified rather than having any special meaning.

Related concepts

Syntax: Single quoted — Structure map

Clickable & Draggable!

Syntax: Single quoted — Related pages: