PHP4 User Manual: Variable-Basics

Source: Internet
Author: User

Chapter 7th. Variable directory list website construction server script \ phpphp user manual fancylanguage.variables.html # language. variables. basics> basic fixed variable scope variable outside PHP variable base
Variable Description: in PHP, It is the name of the variable following the dollar sign. Variable names are case sensitive.
The name of the variable is the same as that of other labels in PHP. A valid variable name starts with a linestring or underline, followed by a linestring, number, or underline. As a regular expression, it would be like this: [a-zA-Z_x7f-xff] [a-zA-Z0-9_x7f-xff] *
Note: a letter is a-z, A-Z, and ASCII character 127 through 255 (0x7f-0xff ).
$ Var = "Bob"; $ Var = "Joe"; echo "$ var, $ Var"; // output "Bob, Joe" $4 site = not yet; // error; start cannot be a number $ _ 4 site = not yet; // valid; start can be an underscore $ täyte = mansikka; // valid: äis ASCII 228.


In PHP 3, variables are assigned values. In other words, when you assign an expression to a variable, the value of the original expression is copied to the target variable.
This means that assigning a variable value to another variable only changes the value of those variables without affecting other variables. For more information, see Expressions.
PHP 4 provides another way for Variable Allocation value: Reference allocation. This means that the new variable is a simple reference of the original variable (this new variable is just a "alias" or "pointing"). Changing the new variable will affect the original variable, and vice versa. This also means that no replication is executed: Therefore, the allocation speed is faster. However, such acceleration only occurs when complicated loops or large arrays and objects are allocated.
Assign a reference. You only need to add "&" before the variable (source variable. For example, the following code snippet outputs My name is Bob twice:

An Important Note: Only one specified variable can be referenced and allocated.

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.