PHP Knowledge points-variables and constants

Source: Internet
Author: User

One, variable

1. Form: $ variable---variable must start with $, followed by the variable name.
2. Delete variable function: unset () is the "referential relationship" between the variable name and the data.
3. There are two ways to transfer values between variables: (the transfer value between variables, must use the reference Pass & symbol)

A. Value passing
is a copy of the value of a variable, assigned to another variable, after copying, two variables are independent of each other

B. Reference delivery
Copy the reference relationship of one variable and assign it to another variable, two variables are associated, point to the same data

4. Variable variable $$ variable

$v 1 = "abc"; This is a string variable whose content is the string "abc"
$ABC = 10; This is an ordinary variable whose content is the number 10
echo $ $v 1; At this point, it's called "mutable variables."

5. Predefined variables (hyper-global variables)
Data type: Hyper-global variables are arrays

A, $_get variable (array): Gets the element and submits the data in Get mode;
b, $_post variable (array): An array of data that is submitted by post.
(Typically, a form form in a Web page is usually post-mode)
C, $_request variable (array): Gets the "sum" of $_post data and $_get data
D, $_server variable (array): Store some request or setup information for server side or client

Second, constant: used to store a data that does not change and does not want to change the identifier.

1, define ("constant name", constant value);
2, const constant NAME = constant value----Const syntax can only be used in the top-most code field (cannot be in curly braces)
3, defined ():
Determine if a constant exists and the result is a Boolean value
$result = defined (a constant name);//The result is true or false

4. Pre-defined constants:
M_pi (PI)
Php_os (operating system)
Php_version (PHP version number)
Php_int_max (the largest integer value in PHP)

5. Magic Variable:
__dir__ (the directory where the current Web page file is located)
__FILE__ (current Web file)
__LINE__ (current line)

PHP Knowledge points-variables and constants

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.