Php entry variable

Source: Internet
Author: User

A variable is a container used to temporarily store values. These values can be numbers, texts, or much more complex data.

PHP has eight variables.

There are four scalar (single value) types: string (character), integer, floating point (decimal), and Boolean (TRUE or FALSE );

Two non-standard (multi-value) types-arrays, objects, and resources (you will see it when interacting with the database) and NULL (it is a special type that does not have any value ).

========================================================== ==========================================

PHP syntax rules:
1. The variable name, also known as its identifier, must begin with the dollar sign ($), for example, $ name.
2. A variable name can contain a combination of letters, numbers, and underscores, for example, $ my_report1.
3. The first character after the dollar sign must be a letter or underscore (not a number ).
4. Variable names in PHP are case sensitive. This is a very important rule. This means that $ name and $ Name are completely different variables.

FAQ:

First, you can use the equal sign (=) (also known as the value assignment operator) to assign values to variables.

Second, variables can be printed without quotation marks; or variables can be printed in double quotation marks; but variables cannot be printed in single quotation marks.

<? Phpecho $ name; // print the variable echo "Hello, $ name" without quotation marks; // print the variable echo 'hello, $ name' in double quotation marks '; // print the variable in single quotes [an error will be reported]?>

 

========================================================== ==========================================

[1] when creating a variable, the most important consideration is to use a consistent naming mode. Some programmers prefer to use variable names with lower-case letters and underlines to separate words ($ first_name). Some programmers prefer to use uppercase letters, for example: $ FirstName (camper ).

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.