Collect form data
Generate dynamic web pages
Processing of string
Dynamic output image
Processing server-side file system
Write web pages supported by database.
Reply tracking control
Processing XML files
Support the use of a large number of network protocols.
Other related operations on the server side.
2. About PHP script running
The written php scripting language needs to be uploaded to the document root directory of the WEB server, and it can be run by accessing the php file managed by the WEB server through a browser. But you can't open the php file directly with a browser, so there is no web server area to parse the code, and the source code is displayed.
Php files can be written in html, css, javascript and other languages, but they need to be marked with opening symbols.
3.PHP language label
& lt? php? & gt
Statements are divided into function execution statements and structure definition statements.
The function execution statement must be followed by a plus sign, and the structure definition statement cannot have a semicolon.
With what? & gt This function execution statement that marks the nearest function can be executed without a plus sign; It is recommended that all function execution statements be marked with a plus sign.
What if? Is> the end of scripting language? & gt don't add this. It is recommended not to add! Many functions (header functions) are not allowed to have any spaces in front of them, so when using the require tag, there must be no spaces at the end of the included php file, otherwise the php file will not be added? & gt just end the label.
4.PHP annotation method
annotation
//
Multi-line comment
/* */Multi-line comments cannot contain single-line comments.
Script comment
#
Document annotation
/** */
Functions of notes:
(1) has written inappropriate code and needs comments. It cannot be deleted immediately.
(2) Comments can be used to write help documents, which can enhance the readability of program code.
(3) Annotation codes can be used to debug programs.
(4) Comments should be written at the top or right of the code.
5. Use white space characters in PHP programs
Blank: space tab newline
White space can enhance the readability of the code.
6, variables
Variables are the core of any programming language, and understanding them is the key to using PHP.
A container used to temporarily store values when using variables.
Variable refers to the quantity that can change at any time during the running of the program, and it is the temporary storage place of data in the program.
Variables can save the data input by the user when the program is running, the result of a specific operation and a piece of data to be output to the web page for display.
In short, variables are simple tools for tracking almost all types of information.
7. declare variables
When a piece of data needs to be used many times, you can declare variables.
Declaration method: $ variable name = value
The type of a variable is determined by the stored value, and the type is not specified before it is declared.
Multiple variables can be declared continuously, such as $ a = $ b = $ c = $ d =“value ".
isset(); A function that determines whether a variable exists.
unset(); The function of deleting (releasing) variables.
8, variable naming
"$" must be used before variables, and the symbol must be used for declaration and use.
Variable names cannot start with a number.
You cannot use php operators, such as+-*/%&; | and so on.
Php can use system keywords as variable names, which is different from other languages.
Php variables are case-sensitive, only variables and constants are case-sensitive, and others are not (PHP function labels, such as ecHo can be written as ECHO or echo, etc. )
Variable names should be meaningful in the project program.
Naming habit: when naming English words, the first letter of the English word is lowercase, the first letter of the following word is capitalized, and other lowercase words, such as aaaBbbCcc.
9. Variable variables (less used)
The variable name of a variable can be set and used dynamically.
& lt? Server-side programming language (abbreviation of professional hypertext preprocessor)
$ one = " # # #
$ two = " one
$ three = " two
$ four = " three
Echo is four dollars. "
";
Echo is four dollars. "
";
Echo four. "
";
echo
Four. "
";
& gt
The output result is:
three
two
one
###
10, reference assignment of variables
Use a&; Add it before the variable to be assigned (original variable), for example: $ a = &;; $ b;
1 1, the type of variable.
There are eight variable types in PHP: four scalars+two compound types (variables that can hold multiple values)+two special types.
Four scalars: integer, Boolean, floating point and string.
Two compound types: array+object.
Two special types: resource type +null
var _ dump(); This function can not only see the types and values of variables.