Applicable scenario:
1, need to generate the Product object has a complex internal structure.2. The properties of the product objects that need to be generated depend on each other, and the generator pattern can be forced to generate order.3. Some
"Purpose": Converts the interface of a class into another interface that the customer wishes, and the adapter mode makes it possible to work together because the interface is incompatible and cannot work together
"Primary Role"
Target role:
Get IP Address
In PHP to get the current visitor's IP address, or relatively simple:
$ip = $_server[' REMOTE_ADDR ']
The above IP sometimes get no real IP address we can operate as follows
$ip = GetIP ();
Convert IP to city and other
Official introduction
The file_put_contents () function writes a string to the file.
This is the same as calling fopen (), fwrite (), and fclose () in turn.
Comparison of Write methods
Let's take a look at how to write a file using Fwrite.
But there are times when you find that you don't achieve what you want in PHP.I do not discuss the specific reasons, PHP practical applications are generally used isset () function to make judgments.Examples are as follows:
The code is
Note: Daniel Bypass, write the people do not spit AH ~99 multiplication Table Presumably everyone is aware of, then how to apply PHP code to achieve such a multiplication table?Implementation effect:
The following is the implementation of the
Example. Const constant Access
The code is as follows
Copy Code
Class Math {Const num=3.14;Public Function Shownum () {return self::num;}}echo Math::num. " ";$math =new Math ();echo $math->shownum ();Results:3.143.14
For statementYou can use a For statement if you have determined how many times the code block has been repeatedly executed.
Grammar
Php
The code is as follows
Copy Code
for (initialization; condition; increment){code
Str_replace can find replacement regular characters,Preg_replace to find replacement carriage return newline characters (\ r \ n)Preg_replace is commonly used in
The code is as follows
Copy Code
getdescription)))?> ">
php: Indicates the earliest version of PHP that supports this function.
function
Description
PHP
Filter_has_var ()
Checks for variables that specify the type of input.
5
FILTER_ID ()
Returns
Zhou 51 friend a piece of code to ask me, said he could not understand this code, think that this code has a problem, the code is similar:
The code is as follows
Copy Code
$array 1 = Array (1, 2);$array 2 = Array (3, 4);$
Take a look at some methods or something. This code is the HTML code can be written directly after the use of JS to implement the deletion of HTML elements. This combination of PHP words to achieve a lot of deletion is much easier. Clicking Add adds
XCache Working principle:
XCache is the open source opcode and var cache, it can speed up PHP is the reason is xcache by caching the user has requested PHP compiled results, Save the PHP compilation cache in the server's memory so that the user can
In PHP's original code installation package, into the etc/pdo_mysql. Let's say your PHP is installed in the/usr/local/php.
Execute/usr/local/php/bin/phpize
2. To compile
Processing of file upload forms The code is as follows:Copy code Let's take a look at the usage of files variables.The $ _ FILES Super global variable is special. It is the unique two-dimensional array in the predefined Super Global array.
Php Tutorial functions-use of system function recursive functions to reuse function constructors/** 1. Internal function: PHP can declare the function inside the function.* The purpose is to call the function internally.* Used to help external
1. When you use file_get_contents or fopen, file, readfile, and other functions to read a url, a variable named $ http_response_header is created to save the http response header, stream_get_meta_data can be used to obtain data streams opened by
Addslashes (); strips tutorial lashes (); // Escape Special characters when operating on the database tutorialDefinition: The addslashes () function adds a backslash before a specified predefined character.Syntax: addslashes (string)Note: By default,
Keywords and special variablesNew, class, extends. Everyone knows about these three items.:, The range resolution operator (also known as Paamayim Nekudotayim) or, more simply, a colon, can be used to access static members, methods, and constants.
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