php- core foundation -day02

The basic syntax:

Case sensitive

Mainly refers to the variable names are case sensitive

Constant usually distinguish, but constant can be set not to distinguish themselves (not recommended)

However, function names are not case

The keywords used in the system is not case-sensitive, such as if, else, for

The statement terminator, with a semicolon

Delete unset (): is the "reference" between the variable name with disconnected data, there is, returns to true , there is no returns false, in fact, if the value of a variable is null , the return is false

Delete unset (): is the "reference" between the variable name with disconnected data

Naming Rules

Industry rules, there are several common naming convention:

1 , can only use uppercase and lowercase letters, underscores ( _ ), digital

2 , the number can not begin with

3 , can not be with their environment (system) keywords same name (such as IF , for , function .....

1 , hump nomenclature:

Example: name ,   myName , myFatherName

2 , Pascal nomenclature:

Example: the Name ,   MyName , MyFatherName

3 , underscore interval method:

示例:name,  my_amemy_father_name

 

. 1 <? PHP
 2  IF ( $ _POST )     // if the post data 
. 3  {
 . 4      $ DATAl = $ _POST [ 'N1'];         // corresponding received data values for each individual table 
. 5      $ DATA2 = $ _POST [ 'N2 '];         // special attention: the value of a string type single table 
. 6      $ Fuhao = $ _POST [' yunsuanfu ' ];
 . 7      IF ( is_numeric ( $ DATAl ) && is_numeric ( $ DATA2 ))     // $ and $ digital DATAl data2 is the number 
8     {    //开始计算
 9         switch($fuhao){
10             case "+":
11                 $result = $data1 + $data2;
12                 break;
13             case "-":
14                 $result = $data1 - $data2;
15                 break;
16             case "*":
17                 $result = $data1 * $data2;
18                 break;
19             case "/":
20 is                  IF ( $ DATA2 == 0 ) {
 21 is                      $ Result = "divisor is not 0" ;
 22 is                  }
 23 is                  the else {
 24                      $ Result = $ DATAl / $ DATA2 ;
 25                  }
 26 is                  BREAK ;
 27          }
 28          echo "evaluates to: Result $ " ;
 29      }
 30      the else {     // otherwise: 
31 is          echo " Please enter a number to calculate " ;
 32      }
 33 }
 34 is  the else {
 35      echo "Please enter the correct page and submit the data!" ;
 36  }
 37 >?
View Code

 

Guess you like

Origin www.cnblogs.com/caoqh/p/11505057.html