Creating a basic string

suggest change

String

Strings are created by wrapping the text in double quotes. Double-quoted strings can evaluate variables and special characters.

$myString = "Some basic text"
$mySecondString = "String with a $variable"

To use a double quote inside a string it needs to be escaped using the escape character, backtick (```). Single quotes can be used inside a double-quoted string.

$myString = "A `"double quoted`" string which also has 'single quotes'."

Literal string

Literal strings do not evaluate variables or special characters. Create one with single quotes.

$myLiteralString = 'Simple text including special characters (`n) and a $variable-reference'

To use single quotes inside a literal string, use two single quotes, or use a literal here-string. Double quotes can be used as-is inside a literal string:

$myLiteralString = 'Simple string with ''single quotes'' and "double quotes".'

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents