1,PHP4 Big Data types
Four scalar data types: integer int, real float (floating point), character Char, Boolean (only two values, true or FALSE)
Two special types: Resource NULL
Two composite data types: Arrays and objects
2>php Common functions
Isset () Function: detects whether a variable is set to a parameter: A parameter that is the return value of a variable name: Returns TRUE if the variable exists, or False (error).
Unset () function: destroying variables
Var_dump (): Print the details of the variable, including the data type
Print_r () Print array
Echo Output string
Print () Output string
The length of the printf () output string
3, common array functions
1>in_array (' string ', $arr): Checks if there is a value in the array; There are two parameters, the first parameter is the value to look for, the second parameter is the array name, the return value is Boolean, and True otherwise false
2> array_search (' value ', $arr): Searches for the given value in the array, returns the corresponding key name with two arguments if successful, the first argument is the value to be found, the second argument is the array name
3>array_key_exists (' $key ', $arr): Checks whether the given key name or index exists in the array and returns TRUE, otherwise false, with two arguments, the first is the key name, and the second is the array name
4>explode (', ', string): Splitting a string into an array has two parameters, the first is a split symbol, the second is a string name, and the return value is a new array after a split
5>implode (', ', $arr): Concatenate an array into a string, have two arguments, the first is the connection identifier, the second argument is the array name, the return value is a new string
6>json_encode (); Encode data in JSON format
7>json_decode (): Encode a string in JSON format
9>array_keys ($arr) to get the key name of the array.
10>array_values ($arr) to get the value of the array.
11>in_array ($value, $arr), retrieves whether $value is in $arr, and returns a Boolean value.
12>array_key_exists ($key, $arr), retrieves the $arr of the array, whether there is $key this key name.
13>array_search ($value, $arr), retrieves whether the $value is in $arr, if there is a return key name.
14>array_reverse ($arr, true) to reverse an array and, if the second argument is true, to persist the key name.
15>array_flip ($arr) Exchange the keys and values of an array
16>count ($arr) Count of array elements
17>array_count_values ($arr) Number of occurrences of all values in the statistics array
18>array_unique ($arr) to move duplicate values in an array
19>sort ($arr), sorted by small to large.
20>rsort ($arr), sorted by large to small.
21>array_merge-merging one or more arrays
22>array_sum ($arr) that sums all the elements of an array.
4, String common functions:
1>MD5 () string encryption
2>base64_encode (string data);
3>base64_decode () Bases64 decoding of strings
4>str_split ($string, 5) divide the string into the array, parameters: 1, the string to be split, 2, a number of strings to divide the city one value
5>explode ("", $str) cuts a string into an array
6>printf (): Format the output string, return the length of the string
7>print (): It's not actually a function (it's a language structure), so you don't have to use parentheses to enclose its argument list, the function is to output the string
8>str_replace (' character to replace ', ' Replace with ', ' string '), string substitution. There are three parameters, the first parameter is: the string to replace the second argument: the first parameter is replaced by who the third argument: is the string name the function returns the replaced string.
9>strtolower (): Converts all letters to lowercase, with only one argument being the string name returning the converted lowercase string.
10>strtoupper (): capitalizes all letters, and only one + parameter is the string name, returning the converted uppercase string.
11>ucfirst (): capitalizes the first letter of the string to uppercase, and only one argument is the string name, returning the converted new string
12>ucwords (): Converts the first letter of each word in a string to uppercase, and only one argument is the string name, returning the converted new string
14>substr ("ABCdef",-3, 1); Intercept string
13>include and require both contain the file meaning: The difference is: when the program encounters a fatal error, the include throws an exception, the program continues execution, then require will produce a serious warning, the program terminates execution.
In order to avoid the error of containing the same file multiple times, we use: include_once require_once to replace these two;
Note: Include require must be added when the file is included ()?? You don't have to add or add.
5 functions on the file
1>file_exists (): Determine if the file exists
2>copy (): Copies a file and stores it as another file.
3>unlink (): Delete a file
4>filesize (): Gets the size of the file
5>filemtime (): Last Modified time for file
6>fopen (): Open a file
7>fgets (): Get a one-line record of a file
8>fread (): Read file
9>fwrite (): Writing to File
10>fclose (): Close an open file pointer
11>file_get_contents () reads the entire file into a string;
12>file_put_contents (): Writes a string to a file two parameters the first is the file name, the second is the string to be written
6php Syntax:
1> understand the difference between single and double quotes: single quotes do not resolve variable names starting with $, double quotes resolve variable names starting with $
2> Linked Database
Mysql_connect (): Open a database connection, three parameters, the first parameter is the address of the database, the second parameter is the administrator name, the third parameter is the password to return a database connection identity
mysql_select_db (): Select a database with two parameters the first parameter is the database name, the second parameter, and the database identity that Mysql_connect returns
mysql_query (): Execute SQL statement to select returns a resource for other types of SQL statements, mysql_query () returns TRUE on successful execution, and FALSE when an error occurs.
mysql_query (' Set names UTF8 '); Set character sets
Mysql_fetch_array (): Gets a row from the result set as an associative array, or as a numeric array, or both
Mysql_fetch_array ($res, Mysql_num) This will be an indexed array
Mysql_fetch_array ($res, MYSQL_ASSOC) This will be an associative array
MYSQL_FETCH_ASSOC (): Gets a row from the result set as an associative array
Mysql_fetch_row (): Gets a row from the result set as an indexed array
MYSQL_INERT_ID (): Get an auto-growing ID just inserted without having to write any parameters
3> Why use Session control?
A: The HTTP protocol is stateless, meaning that the HTTP protocol does not have a built-in mechanism to maintain state between two things
What is a cookie?
A: A cookie is a session control that is stored in the client's browser to track and identify the user, enabling multiple page values to be passed. Storage address: C:\Documents and Settings\administrator.zourinet\cookies
What are the categories of cookies?
A: Persistent cookie: A cookie that is set to expire time is called a persistent cookie. Regardless of whether the browser is closed, the value in the cookie will wait until the expiration time to disappear.
Session Cookie: A cookie that is not set to expire time is called a session cookie. Cookies disappear when the browser is closed or when the computer is restarted
Set cookies
Setcookie (String $name, [string $value],[int $expire])
Note: There is no output in front of Setcookie
Setcookie ("name", "value", "Expiration Time") "Note: The expiration time must be a number of seconds"
with cookies
Use $_cookie["name"] to read the COOKIE, the $_cookie as a normal array can be
Delete Cookies
Setcookie ("name", "", Time ()-1);
PHP Common functions