W3school PHP Tutorial (1) PHP Basics. This note only extracts the notes for php, and does not write any content about operators or simple judgments. 1 string 1.1 strlen () function compute string length? Phpechostrlen.
1 string
1.1 strlen () function compute string length
The 1.2 strops () function searches strings or characters in strings.
2 array
2.1 Numeric array with digit ID key
Auto-assigned ID key:
$ Names = array ("a", "B", "c"); manually allocate the ID key:
$ Names [0] = "a"; $ names [1] = "B"; $ names [2] = "c"; use the ID key:
2.2 Associate each ID key in the array with a value
Assign values as keys:
$ Ages = array ("a" => 10, "B" => 20, "c" => 30); another method:
$ Ages ["a"] = "10"; $ ages ["B"] = "20"; $ ages ["c"] = "30"; use the ID key:
2.3 Multi-dimensional arrays an array containing one or more arrays (omitted)
3 cycles
3.1 while
"$ I ++ ;}?>
3.2 do... while
";}While ($ I <5) ;?>
3.3
";}?>
3.4 foreach
The foreach statement is used to traverse the array cyclically. each time a loop is executed, the value of the current array element is assigned to the value variable (the array pointer is moved one by one), and so on.
Syntax
Foreach (array as value) {//...} example: output the value of the given array
";}?>
4 Functions
4.1 pass parameters
";}Echo" my name is "; writeName (" Gang "," Li "); echo" my name is "writeName (" San "," Zhang ");?>
4.2 Return value
5. form processing
The $ _ GET variable is used to collect the value of a form from method = "get.
The $ _ POST variable is used to collect the value of a form from method = "post.
5.1 $ _ GET variable
Form. php
Welcome. php
Welcome .
You are Years old!
5.2 $ _ POST variable
Unlike $ _ GET:
$ _ POST has no limit on the amount of sent information, while $ _ GET has a limit of 100 characters.
$ _ POST does not reflect the value in the form at the url, while the url passed by $ _ GET can be added to favorites.
5.3 $ _ REQUEST variable
The $ _ REQUEST variable can be used to obtain the results sent to form data through the get and post methods.
Bytes. 1 string 1.1 strlen () function compute string length? Phpecho strlen ("hello world...