[PHP] PHP entry-Chapter 1-php Tutorial

Source: Internet
Author: User
Tags type null
[PHP] PHP entry Chapter 1: PHP case sensitivity

1) all user-defined functions, classes, and keywords are case-insensitive.

The output is consistent as follows:

Echo "hello world"

Echo "hello world"

EcHo "hello world"

2) user-defined variables, Case Sensitive

Only the first line outputs the correct color as follows

 ";echo "My house is " . $COLOR . "
";echo "My boat is " . $coLOR . "
";?>
2. global keyword

1) use the global keyword before the variables in the function to access the global variables.

 
2) in PHP, all GLOBAL variables are stored in the $ GLOBAL [index] array, the subscript stores all GLOBAL variables, and the subscript contains the variable name, this array can also be accessed in the function and can be used to directly update global variables.

 
3. static keywords

After the function is executed, local variables are deleted. sometimes static keywords are used to make the variables in the function memory.

 

IV. basic output method

Differences between echo and print:

Echo-can output more than one string

Print-only one string can be output and 1 is always returned.

Tip: echo is a little faster than print because it does not return any value.

 ";print "Study PHP at $txt2";print "My car is a {$cars[0]}";?>


5. string and integer

1) a string is a character sequence, such as "Hello world! ".

A string can be any text in quotation marks. You can use single or double quotation marks:

2) integer

PHP var_dump () returns the data type and value of the variable.

 "; $ X =-345; // negative var_dump ($ x); echo"
"; $ X = 0x8C; // hexadecimal number var_dump ($ x); echo"
"; $ X = 047; // eight-digit var_dump ($ x);?>

Result:

int(5985) int(-345) int(140) int(39)


VI. array

$cars=array("Volvo","BMW","SAAB");var_dump($cars);


Result:

Array (3) {[0] => string (5) "Volvo" [1] => string (3) "BMW" [2] => string (4) "SAAB "}

7. NULL value

NULL indicates that the variable has no value. NULL is the only possible value of the data type NULL. NULL indicates whether the variable is NULL. you can set the value to NULL to empty the variable.

 

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.