After so many days, we continue to record 4th-records today ~ Chapter 5 ...... 1. String operations and regular expressions * remove null or other characters: trim (), ltrim (), rtrim (), that is, chop (); * use HTML Format: nl2br (), "n" "br" * formatted output: printf (), which is basically the same as the usage in C * addslashes () and addcslas
After so many days, we continue to record 4th-records today ~ Chapter 5 ...... 1. String operations and regular expressions * remove null or other characters: trim (), ltrim (), rtrim (), that is, chop (); * use HTML Format: nl2br (), "\ n" "br/" * formatted output: printf (), which is basically the same as the usage in C * addslashes () and addcslas
After so many days, we continue to record 4th-records today ~ Chapter 5 ......
1. String operations and Regular Expressions
* Remove spaces or other characters: trim (), ltrim (), rtrim (), that is, chop ();
* HTML Format: nl2br (), "\ n">"
"
* Formatted output: printf (), which is basically the same as that in C.
* Addslashes () and addcslashes (), as well as stripslashes () and stripcslashes ()
First, the addslashes () function adds backslashes before single quotation marks, double quotation marks, backslashes, and NULL characters in string parameters for escape. The parameter has only one; in php.net, it is strongly recommended that you use the escape function specified by DBMS (for example, MySQL is mysqli_real_escape_string (), PostgreSQL is pg_escape_string () to insert data into the database ()).
The addcslashes () function has two parameters. The second parameter is used to specify the characters to be escaped. It can be said that the parameters are handled in the C language style. For details, refer to PHP: addslashes-Manual.
Stripslashes () is to remove the escape backslash from the string parameter; stripcslashes () returns the string after the inversion. It can recognize "\ n", "\ r",... octal and hexadecimal descriptions similar to C.
* Other functions include string segmentation and connection, matching the position of a substring from a string, replacement, and so on ......
* In addition, the content of the regular expression should be detailed for reference;
2. code reuse and function writing
This is more basic ...... Notes
* Require () and include (). The two are almost the same. The difference is that if require () fails to return an error when the reference fails, the include () Failure Returns a warning. In addition, the running efficiency of require_once and include_once is lower than that of require and include;
* PHP references files regardless of the suffix. and if you want to execute php code in the referenced files, you need the correct php mark;
* Automatic File Reference: Configure auto_prepend_file and auto_append_file (each file will be added), or use the. htaccess file to specify a directory. However, each access will process the file once, resulting in efficiency issues;
* Functions are case insensitive and variables are case sensitive;
* You can call func_num_args () to obtain the number of input parameters. func_get_arg () gets a parameter at a time, and func_get_args () returns an array of parameters;
Well, that's all.