1 code block PHP to Or Mark
2 PHP variable starts with $
3 String Processing:
3.1 string connector is. Number
3.2 String Lengths strlen (String)
3.3 substring position strpos (STR1,STR2) returned false when not found
4 Array $Arryname = Array (items,items) or $Arryname = Array (conststring=>items,conststring=>items) or $Arryname [index ]=items or $Arryname [Conststring]=itmes or $Arryname [Index]=array ....
5 The foreach statement is a foreach (array as value) which differs from other languages
6 functions define function functionname (parameter) {}
7 The value of the fetch request parameter $_get["Formitmename"] GET
$_post[value of "Formitmename"] POST
$_cookie[value of "CookieName"] COOKIE
$_request["Questname"] get post cookie, etc.
8th Issue Date Created Mktime (HOUR,MINUTE,SECOND,MONTH,DAY,YEAR,IS_DST)
Example $tomorrow = Mktime (0,0,0,date ("M"), Date ("D") +1,date ("Y"));
Formatted date datetime (Format[,timestamp])
Example echo Date ("y/m/d"); echo "
"; Echo Date (" Y.M.D ");
The 9 include () function obtains all the text in the specified file and copies the text to a file that uses the Include function.
The Require () function is the same as include (), and the difference is how it handles the error.
The Include () function generates a warning (but the script continues), and the Require () function generates a fatal error (fatal error) (the script stops executing after the errors occur).
The fopen () function is used to open the file in PHP.
$file =fopen ("Welcome.txt", "R");
The fgets () function is used to read a file from file to line.
The fgetc () function is used to read files verbatim from a file.
Fclose ($file); Close File
if (feof ($file)) echo "End of File";
Fclose ($file);
11 using PHP's global array $_files, you can upload files from a client computer to a remote server.
if (($_files["File" ["type"] = = "Image/gif")
|| ($_files["File" ["type"] = = "Image/jpeg")
|| ($_files["File" ["type"] = = "Image/pjpeg"))
&& ($_files["File" ["Size"] < 20000))
{
if ($_files["file" ["error"] > 0)
{
echo "Return Code:". $_files["File" ["Error"]. "
";
}
Else
{
echo "Upload:". $_files["File" ["Name"]. "
";
echo "Type:". $_files["File" ["type"]. "
";
echo "Size:". ($_files["File" ["Size"]/1024). The Kb
";
echo "Temp file:". $_files["File" ["Tmp_name"]. "
";
if (file_exists ("upload/". $_files["File" ["Name"]))
{
echo $_files["File" ["Name"]. "already exists.";
}
Else
{
Move_uploaded_file ($_files["file"] ["Tmp_name"],
"Upload/". $_files["File" ["name"]);
echo "Stored in:". " Upload/". $_files["File" ["Name"];
}
}
}
Else
{
echo "Invalid file";
}
The Setcookie () function is used to set the cookie.
Note: the Setcookie () function must precede the label.
Setcookie (name, value, expire, path, domain);
Setcookie ("User", "Alex Porter", Time () +3600);
PHP's $_cookie variable is used to retrieve the value of the COOKIE.
Print a cookie
echo $_cookie["user"];
A-to-View all cookies
Print_r ($_cookie);
Use the Isset () function to confirm that a cookie has been set
if (Isset ($_cookie["user"))
When you delete a cookie, you should change the expiration date to a past point in time
Setcookie ("User", "", Time ()-3600);
13 Before you store user information in a PHP session, you must first start the session.
Note: the Session_Start () function must precede the label:
The correct way to store and retrieve session variables is to use the PHP $_session variable:
Session_Start ();
Store session Data
$_session[' views ']=1;
To delete some session data, you can use the unset () or Session_destroy () function
The unset () function is used to release the specified session variable: unset ($_session[' views ');
The Session_destroy () function completely ends the session, Session_destroy ();
Note: Session_destroy () resets the session and you will lose all stored session data.