A string is a continuous character sequence consisting of numbers, letters, and symbols. Each character in a string occupies only one byte. In PHP, there are three methods to define strings: single quotes (), double quotes ("), and delimiters (& lt ;).
What is a string )?
A string is a continuous character sequence consisting of numbers, letters, and symbols. Each character in a string occupies only one byte.
In PHP, there are three methods to define strings: single quotation marks ('), double quotation marks ("), and delimiters (<).
Single quotation marks and double quotation marks are often used to define strings. they are defined as follows:
Single quotes
Double quotation marks
The difference between single quotes and double quotes is that variables contained in double quotes are automatically replaced with actual values, while variables contained in single quotes are output based on common characters, what does this mean? let's look at the example below
Examples of the differences between single quotes and double quotes defining strings
"; // Output short Mark echo '$ I'; // output in single quotes?>
The sample running result is as follows:
One thing to note here is that \ n and \ r are no different in Windows systems and can all be used as carriage returns. But in Linux, there are two effects. in Linux, \ n indicates switching to the next line, but it does not return to the first line; while \ r indicates that the cursor returns to the first line, however, if you are using a Linux operating system, try again.
If we use "\" for non-escape characters, "\" will be output along with the output.
When defining some simple strings, using single quotes is a better way to handle them. If double quotation marks are used, PHP will take some time to process string transfer and variable parsing. Therefore, when defining a string without special requirements, we 'd better use single quotation marks.
Identifier
The identifier <) is supported from PHP4.0. The end string is the same as the end string. The format of the delimiter is as follows:
$ String = <str string to be output
Str indicates the specified identifier.
Delimiter example
The code is as follows:
\ $ I content: $ istd?>
Code running result:
The end identifier must start with another line and cannot contain spaces. There are other characters or symbols before and after the identifier, and a system error may also occur, including comments.
In the next section, we will introduce "integer" in the scalar data type )".
The above is php: detailed description of the string data type instance. For more information, see other related articles in the first PHP community!