0x00 Serialization function
Serialize (): Returns a string with variable type and value
Unserialize (): Want to change the serialized string back to the value of PHP
Test code:
Class test{var $a;var $b;function __construct ($a, $b, $c) {$a = $a;$
Simple Factory mode:
① abstract base class: class definition abstract Some methods to implement in subclasses② inherits from the abstract base class: Implementing an abstract method in a base class③ Factory class: Used to instantiate objects
What
One, Custom functionThe custom function is our own defined function, in PHP the custom function format is as follows:function Funname (arg1, arg2, Arg3 ...) {Todoreturn values;}
The code is as follows
Copy Code
function
Before PHP5, each PHP framework, if you want to implement the automatic loading of classes, is generally a kind of convention to implement a traversal directory, automatically load all the files that meet the Convention rules of the class or
In the course of learning "ten days to learn PHP", when you see the problem of database connection, due to the lack of knowledge, encountered difficulties. So find a friend to help write a PHP applet, posted here, hope for everyone can help. I wrote
When you register on a forum, there is usually an e-mail address verification function, when you enter an illegal format, there will be some kind of error message. We can use the following rule expressionEreg ("^[a-za-z0-9_] @[a-za-z0-9-]. [ a-za-z0-
The number of times to execute the same code set is used in PHP. The basic syntax of the author is as follows:
The For loop is just a little bit more code, and loops are added to it. And one of the common tasks involved in the cycle is:
Sets the
Guide:Capital Y represents a four-digit year, while lowercase y represents a two-digit number for the year;Lowercase m represents the number of months (with leading), while lowercase n indicates the number of months without leading.echo Date ('
Why use Trait
The PHP language uses a typical single inheritance model, in which we first write a generic root class, implement basic functionality, then extend the root class, create more specific subclasses, and inherit the implementation
If your PHP site/var/log/httpd/error_log the following error:PHP Fatal error:call to undefined function mcrypt_get_block_size () In/var/www/html/miniblog/system/classes/class_ des.php on line 40Heart presumably is MCrypt not installedThe
The array_search () function is the same as the in_array () function. You can find a key value in the array. If this value is found, the key name of the matching element is returned. If not found, false is returned.If the third parameter strict is
The file_get_contents () function reads the entire file into a string.Like file (), the difference is that file_get_contents () reads the file into a string.The file_get_contents () function is the preferred method for reading the file content into
The in_array () function searches for the given value in the array.SyntaxIn_array (value, array, type)*/ The code is as follows:Copy code $ OS _list = array ("mac", "nt", "irix", "linux"); // defines an arrayIf (in_array ("irix", $ OS _list) //
First create the/tmp/php-cgi.sock file and change it to www-data:# For nginx users, it seems that they must belong to the nginx user group before they can be properly used and not verifiedSudo chown www-data/tmp/php-cgi.sockTo nginx. conf, if you
The PHP pattern modifier, also known as the pattern modifier, is used outside the delimiters of regular expressions. It is mainly used to adjust the interpretation of regular expressions, and extends some functions of regular expressions in
ExampleWe use preg_replace and str_ireplace to replace The code is as follows:Copy code Public static function filterStr ($ value){If (empty ($ value )){Return "";}$ Value = trim ($ value );$ Badstr = array ("x00", "% 00", "r", "&", "," '"," ",
If you have a large array and all you need to do is find an existing given value, you can use in_array () to return true or false. The following code outputs "Not found in this array" because you will find an existing "Alber" in $ namesArray ".$
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service