PHP string is a sequence of characters i.e., used to store and manipulate text. PHP supports only 256-character set and so that it does not offer native Unicode support. There are 4 ways to specify a string literal in PHP.
- single quoted
- double quoted
- heredoc syntax
Single Quoted
We can create a string in PHP by enclosing the text in a single-quote. It is the easiest way to specify string in PHP.
For specifying a literal single quote, escape it with a backslash (\) and to specify a literal backslash (\) use double backslash (\\). All the other instances with backslash such as \r or \n, will be output same as they specified instead of having any special meaning.
Example:
0 Comments