PHP Tutorial variable definition _ PHP Tutorial-php Tutorial

Source: Internet
Author: User
PHP Tutorial variable definition. Variable variables in PHP are used to store values, such as numbers, text strings, or arrays. Once a variable is set, we can reuse it in the script. All the variables in PHP
Variables are used to store values, such as numbers, text strings, or arrays.
Once a variable is set, we can reuse it in the script.
All variables in PHP start with the $ symbol, and the variable names are case sensitive.
The correct method for setting variables in PHP is:
$ Var_name = value; PHP users often forget the $ symbol before the variable. In this case, the variable will be invalid.
Although variables do not need to be initialized in PHP, this is a good habit. Uninitialized variables have default values of their type-FALSE, zero, null string, or empty array.

The code is as follows:


$ Var = 'php ';
$ Var = 'tutorial net ';
Echo "$ var, $ Var"; // output "PHP, tutorial network"
$4 site = 'not Yun'; // The name of an invalid change. it must start with a number.
$ _ 4 site = 'not Yun'; // valid variable name; starting with an underscore
$ I site is = 'mansikka '; // valid variable name; Chinese
?>


Variable naming rules
The variable name must start with a letter or underscore.
Variable names can only contain letters, numbers, and underscores.
Variable names cannot contain spaces. If the variable name is composed of multiple words, it should be separated by underscores (for example, $ my_string) or begin with an uppercase letter (for example, $ myString ).

Variable variables in the http://www.bkjia.com/PHPjc/320761.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/320761.htmlTechArticlePHP are used to store values, such as numbers, text strings, or arrays. Once a variable is set, we can reuse it in the script. All variables in PHP...

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.