Home > Article > Backend Development > PHP entry variable string, PHP entry variable_PHP tutorial
A string is just a block of characters enclosed in quotation marks: letters, numbers, spaces, punctuation marks, etc.
All listed below are strings:
?1 2 3 4 |
'Huige'
"In watermelon sugar"
'100'
'August 2, 2011'
|
FAQ:
【1】When creating a string, you can use single quotes or double quotes to encapsulate characters. In addition, the same type of quotes must be used at the beginning and end of the characters.
【2】If the same quotation mark appears in the middle of the string, you can place a backslash in front of the problematic character (the problematic character here is a double quotation mark, and you will learn about other problematic characters later) , which escapes:
?1 2 3 |
<?php
$var = "Define "platitude", please." ;
?>
|
Another way is to use single quotes (this way you use single quotes when printing double quotes and vice versa):
?1 2 3 |
<?php
$var = 'Define "platitude", please.' ;
?>
|
【3】If the same variable is assigned twice (for example: $book), the new value will overwrite the old value.
?1 2 3 4 |
<?php
$book = 'High Fidelity' ;
$book = 'The Corrections' ;
?>
|
Print the result yourself, so you can verify whether the new value overwrites the old value.