Home > Backend Development > PHP Tutorial > PHP entry variable string_PHP tutorial

PHP entry variable string_PHP tutorial

WBOY
Release: 2016-07-13 10:35:33
Original
830 people have browsed it

A string is just a block of characters enclosed in quotes: letters, numbers, spaces, punctuation, etc.

All listed below are strings:

'Huige'
"In watermelon sugar" 
'100' 
'August 2, 2011'
Copy after login

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:

<?php
	$var = "Define \"platitude\", please.";
?>
Copy after login

Another way is to use single quotes (this way you use single quotes when printing double quotes and vice versa):

<?php
	$var = 'Define "platitude", please.'; 
?>
Copy after login

【3】If the same variable is assigned twice (for example: $book), the new value will overwrite the old value.

<?php
	$book = 'High Fidelity'; 
    $book = 'The Corrections'; 
?>
Copy after login

Print the result yourself so that you can verify whether the new value overwrites the old value.

I wrote the printing of variables here ====》》PHP entry variables

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/743388.htmlTechArticleA string is just a block of characters enclosed in quotation marks: letters, numbers, spaces, punctuation marks, etc. The following are all strings: 'Huige'"In watermelon sugar" '100' 'Augu...
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template