PHP Tutorial Variable Definition_PHP Tutorial

WBOY
Release: 2016-07-21 15:43:27
Original
852 people have browsed it

Variables in PHP
Variables are used to store values, such as numbers, text strings, or arrays.
Once a variable is set, we can use it repeatedly in the script.
All variables in PHP start with the $ symbol, and variable names are case-sensitive.
The correct way to set variables in PHP is:
$var_name = value; Beginners to PHP often forget the $ sign in front of the variable. If you do that, the variable will be invalid.
Although initializing variables is not required in PHP, it is a good practice. Uninitialized variables have a default value of their type - FALSE, zero, the empty string, or the empty array.

Copy code The code is as follows:

$var = 'PHP';
$ Var = 'Tutorial Network';
echo "$var, $Var"; // Output "PHP, Tutorial Network"
$4site = 'not yet'; // Illegal name change; starts with a number
$_4site = 'not yet'; // Legal variable name; starts with underscore
$i site is = 'mansikka'; // Legal variable name; can be in Chinese
?>

Naming rules for variables
Variable names must start with a letter or underscore "_".
Variable names can only contain alphanumeric characters and underscores.
Variable names cannot contain spaces. If the variable name consists of multiple words, they should be separated by underscores (such as $my_string) or start with a capital letter (such as $myString).

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/320761.htmlTechArticleVariables in PHP Variables are used to store values, such as numbers, text strings, or arrays. Once a variable is set, we can use it repeatedly in the script. All variables in PHP...
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