Home >Backend Development >PHP Tutorial >Theoretical basis of debit and credit accounting method. A good basic PHP study note.
1. Four representation forms of PHP fragments.
Standard tags:
short tags: . Set asp_tags=on in ini, the default is off
script tags:
2. PHP variables and data types
1) $variable , variables start with letters, _, There can be no spaces
2) Assignment $variable=value;
3) Weak type, direct assignment, no need to explicitly declare the data type
4) Basic data types: Integer, Double, String, Boolean, Object (object or class), Array (Array)
5) Special data types: Resource (reference to third-party resources (such as database)), Null (empty, uninitialized variable)
3. Operator
1) Assignment operator: =
2) Arithmetic Operations:+,-,*,/,%(molding)
3) Connection operator:, no matter what the operating number is, it is used as string, and the result returns String
4) Combined Assignment Operators =, *=, /=, -=, %=, .=
5) Automatically Incrementing and Decrementing automatic increase and decrease operators:
(1)$variable+=1 <=>$variable++;$variable-=1 <=>$variable-, just like C language, do other operations first, then ++ or -
(2) ++$variable, -$variable, do ++ or - first, then do other operations
6) Comparison operator: = = (left side equals right side), != (the left side is not equal to the right side), = = = (the left side is equal to the right side, and the data type is the same), >=, >, <, <=
7) Logical operators: ||ó or, &&óand, xor (When there is and only one of the left and right sides is true, return true),!
4. Comments:
Single-line comments: //, #
Multi-line comments: /* */
5. Each statement ends with;, and Same as java
6. Define constants: define(“CONSTANS_NAME”,value)
7. Print statement: print, same as c language
8. Process control statement
1) If statement:
(1) if(expression)
{
//code to excute if expression evaluates to true
}
(2)if(expression)
{
}
else
{
}
(3)if(expression1)
{
}
elseif(expression2)
{
}
else
{
}
2) swich statement
switch ( expression )
{
case result
// execute this if expression results in result1
break;
case result
// execute this if expression results in results2
break;
default:
// execute this if no break statement
// has been encountered hitherto
}
3) ? Operator:
(expression)?returned_if_expression_is_true:returned_if_expression_is_false;
4) while statement:
(1) while (expression)
{
{
// code to be executed
} while (expression);
5) for statement:
for (initialization expression; test expression; modification expression) {
// code to be executed
}
6) break; continue
9、 Write function
1) Define function :
function function_name($argument1,$argument2,…) //Formal parameter
{
//function code here;
}
2) Function call
function_name($argument1,$argument2,…); //Formal parameters
3) Dynamic Function Calls:
");
numberedHeading("Doodads"); /*When called for the first time, print $num_of_calls value is 2, because the variable is static type, static type is resident in memory*/
print("Finest in the world< ;p>");
?>
6) Passing value (value) and passing address (reference):
Passing value: function function_name($argument)
< html>