1. Basic grammar and writing format of php5.4
Opening of the short label mode:
; Short_open_tag
The delimiter for the PHP statement;
<?php$php=true;if ($php) {echo "It is true";//Semicolon description}//curly brace End;?>
Use the format of the function:
1. Return value function name ()
2. Return value function name (parameter, parameter ...) )
3, Function name (parameter, parameter:, return variable)
4. Return value function name (...) ) The calling character
2. Variable and variable data type of php5.4
The variable starts with $, can only be a letter or an underscore, consisting of letters, numbers, underscores, numbers cannot begin
<?php$title= "php100.com",//true$title123= "php100.com";//true$123tiele= "php100";//error$_title= "php100.com" ;//true[email protected] #title = "php100";//error$url= "php100";//trueecho $url;//Output @urlunset ($url);//delete variable Urlecho $ Url No data output?>
Scheme for variable naming:
1. Direct connection between $titlekeyword words
2, $title _keyword words directly with _ link
3, $titleKeyword the first letter of the word capital
Data type:
1. String single quotation mark (simple quotation mark) or double quotation mark (functional quotation mark)
2, Plastic integer-2147 4836 48 to +2147 4836 47 (32-bit)
3, float type float or double 1.8E+308
4 Boolean Boolean True or False
5. Arrays Array
6. Object
7. Resource type resource system data resources
3. System constants and custom constants for php5.4
Start with a letter or an underscore, divided into system constants and custom constants
System constants:
__file__ PHP program file name and path
__line__ Functions of PHP programs
Name of the __class__ class
Custom constants:
BOOL Define ("name", "value")
<?phpdefine ("Color", "red"), Echo COLOR. " <br> ";? >
Practice part:
Can be mixed with HTML code
Last line can not write semicolon
<?php$abc= "php100.com"; Echo $abc;? >
Variable Value re-assignment
<?php$abc= "php100.com"; $abc = "www.php100.com"; Echo $abc;? >
Variable variable
<?php$a= "B"; $ $a = "123"; echo $b;? >
The output of the string
<?php echo ' 00000000000 ';? >
Escaped single quotation mark
<?php echo ' 0000\ ' 0000000\\ ';? >
Output I Hava
<?php$a=50;echo "I Hava $a";? >
Output I Hava $a
<?php$a=50;echo ' I hava $a ';? >
int -
<?php$a=50;var_dump ($a);? >
string ' # ' (length=2)
"<?php$a="; var_dump ($a);? >
float 3.14
<?php$a=3.14;var_dump ($a);? >
Boolean true
<?php$a=true;var_dump ($a);? >
Boolean false
<?php$a=false;var_dump ($a);? >
Array (size=4) 0 = int 2 1 = int 3 2 = int 4 3 = int 5
<?php$a=array (2,3,4,5); Var_dump ($a);? >
string ' 123ABC ' (length=6)
<?php$a= "123ABC"; var_dump ($a);? >
int 123
<?php$a= "abc123"; $b = (int) $a; var_dump ($b); >
int 0
<?php$a= "abc123"; $b = (int) $a; var_dump ($b); >
Boolean true
<?php$a=1; $b = (bool) $a; Var_dump ($b);? >
Boolean false
<?php$a=0; $b = (bool) $a; Var_dump ($b);? >
Boolean false
<?php$a= ""; $b = (bool) $a; Var_dump ($b); >
Boolean true
<?php$a= "ASDFGHR"; $b = (bool) $a; Var_dump ($b); >
System variables
9
C:\wamp\www\a_com\test.php
<?phpecho __line__. " <br> "; Echo __file__;? >
System Customization
123
<?phpdefine ("NA", "123"), Echo NA; >
This article is from "Jerry" blog, please make sure to keep this source http://alipay.blog.51cto.com/7119970/1537575