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);$
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 code is as follows:Copy code $ A = 'CC ';$ B = $ a; // $ a and $ B point to the same memory address$ A = 'DD ';Echo $ B;/*The address pointing (similar to pointer) function in php is not implemented by the user,It is implemented by the Zend
Php Tutorial array sorting rsort arsort asort$ Full_name = array ();$ Full_name ["Roger"] = "Waters ";$ Full_name ["Richard"] = "Wright ";$ Full_name ["Nick"] = "Mason ";You may be the value in the array to be sorted. For example, assume that the
Number index array;Non-numeric index array;Array operator;Two-dimensional array and multi-dimensional array;Array sorting;Multi-dimensional array sorting;Sorts the array;Execute other array operations;Number index arrayLike the array in C #, you can
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