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

PHP entry variable string_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 10:35:33841browse

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'

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.";
?>

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.'; 
?>

【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'; 
?>

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...
Statement:
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