First, the PHP concept
Hypertext preprocessor hypertext Preprocessor, is an open source scripting language, grammar absorbs the C language, Java,perl features, for the field of web development,
PHP is the process of embedding a program into an HTML document, which is more efficient.
Second, the operating environment
Guaranteed to be able to run PHP:
Test: Echo "abc";
Ensure that the time zone is set correctly:
Test: Echo Date ("y-m-d h:i:s");
Ensure that the module is set correctly:
Test: New Mysqli ("localhost", ' root ', ' 123 ');
Third, the grammatical environment
Syntax One:
<?php
..... Here is the PHP code
?>
Syntax Two:
<script language= "PHP" >
.... Here is the PHP code
</script>
Special: (Influence of <> rear carriage return)
<?php
Echo ' 234 '
If there's nothing underneath, no end, no effect.
If the write end will output the following carriage return as a space.
<?php Front Write enter will output a space before 234
Case:
Variable names, constants are case-sensitive
function name, system keyword not differentiated
Iv. variables
meaning: an "identifier" that contains a name and a value.
$a = 1;
Note: as soon as the $ symbol appears, followed by the next character, it will be recognized as a variable
The variable must be assigned a value, and the variable is modified if it is assigned two times.
Use the time for $a remember to bring the $ symbol
isset () determine if a variable exists
Presence not true does not exist false if NULL then output is False
unset () Delete
Disconnects the reference relationship between the variable name and the data, rather than deleting the data.
the way of passing values between variables: default values are passed, and if passed by reference, they need to pass the symbol &
value passing: refers to a copy of the data contents of a variable, assigned to another variable. Two variables are independent of each other.
For example: $v 1=1;
$v 2 = $v 1;
$v 1++;
echo "$v 1, $v 2"
The output 2,1
reference passing: refers to a copy of the reference relationship of a variable, assigned to another variable, when changing one data, the other data will also change.
For example: $v 1=1;
$v 2 = & $v 1;
$v 1++;
echo "$v 1, $v 2"
The output 2,2
However, when you delete a variable in unset (), it does not affect the other data.
mutable variables: (only available in PHP)
Refers to the name of a variable and another variable.
$v 1 = "abc"; This is a string variable whose content is the string "abc"
$ABC = 10; This is an ordinary variable whose content is the number 10
echo $ $v 1; At this point, it's called "mutable variables."
Predefined variables: Super Global variables, all arrays
PHP predefined variables are for all scripts, and PHP provides a large number of predefined variables for the script. These variables represent all external variables as built-in environment variables, and the error information is represented as a return header.
It is scoped to a hyper global scope, which means that they are available in all scopes of a script.
Scope:
global scope: defined outside the function
local scope: defined within a function, used only within a function
$GLOBALS $_server $_request $_post $_get $_files $_env $_cookie $_session
$_get (Array)
In HTML
form One :
<form action= "abc.php" method= "Get" >
Item 1: <input type= "text" name= "UName"/>
Item 2: <input type= "password" name= "upswd"/>
<input type= "Submit" value= "Submission"/>
</form>
form two :
<a href= "abc.php?uname=test1&upswd=123" > Text ... </a>
form three :
<script>
Location.href = "abc.php?uname=test1&upswd=123"; Using the property href of the Location object
</script>
form Four :
<script>
Location.assign ("abc.php?uname=test1&upswd=123"); Method of using the Location object assign ()
</script>
in PHP
<?php
$v 1 = $_get[' uName '); Single quotes can also be double quotes, essentially a string, which is actually the key name of the array (subscript)
$v 2 = $_get[' upswd '); The key name must be exactly the same as the name at the time of submission (case-sensitive)
?>
The above is put into separate variables and then output.
Or you can use all the output array methods
<?php
Var_dump ($_get);
?>
$_post (Array)
As with get, usually, the form form in a Web page is generally post, and get is mainly embodied in the other 3 forms.
$_request (Array)
All data for Get and post can be submitted
If the get and post data have the same name, post overwrites the get data.
Request_order = "GP"; This is the default value, and G represents get,p for post
Instead: Request_order = "PG", in reverse order
PHP Introduction variables