This article summarizes some of the functions commonly used in PHP application development, these functions have character operation, file operation and some other operations, share for everyone reference. Specifically as follows:
1, PHP encryption
String is a piece of cake, I summarize some common processing string functions.
1. Determine the length of a string
This is one of the most obvious examples of the article, the question is how we can determine the length of a string, and here we
Here are some functions that use a higher frequency ...
1. Generating random String functions
function Random ($length) {$hash = @#@#;$chars = @ #ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz @#;$max = strlen ($chars)-1;Mt_srand
Getenv-Gets The value of an environment variable
DescriptionString
getenv(String varname)
Returns the value of the environment variablevarname, or FALSE on an error.
// Example use of getenv()$ip = getenv('REMOTE_ADDR');// Or simply
Index.html Demo: Php+jquery+mysql implementation of "Top" and "Step" function php+jquery+mysql "Top" and "Step" function very good, very powerful! Too bad! -->do.phpInclude_once ("connect.php");$action = $_get[' action '];$id = 1;$ip =
0x01 backgroundFirst we understand the next wide-byte injection, which stems from the programmer setting the MySQL connection with an error configured as: Set CHARACTER_SET_CLIENT=GBK, which causes an injection vulnerability caused by the encoding
PHP Common methods
1, PHP encryption and decryptionPHP encryption and decryption functions can be used to encrypt some useful strings stored in the database, and by reversible decryption of the string, the function uses Base64 and MD5 encryption
This article describes how to call Sina api based on ip addresses to obtain city names and convert them to pinyin. For more information, see the following functions:
1. get the current IP address,
2. call Sina API to obtain the current city.
3.
Php is simple and practical to obtain the client ip address. Php obtains the client ip address. it is simple and practical to use functiongetOnlineIP () {$ cipgetenv (HTTP_CLIENT_IP); $ xipgetenv (response); $ ripgetenv (REMOTE_ADDR); $ srip $ _ php
Some ideas about how to obtain the real ip address of the client are not necessarily correct, but at least the correct rate is much better.
The code is as follows:
Function GetIP (){
If (getenv ("HTTP_CLIENT_IP") & strcasecmp (getenv
How does php obtain the client ip address and the specific implementation code of the province and city .. Thank you .. ------ Solution ------------------ how many IP address APIs are provided? Sina's IP address query interface: int.dpool.sina.com.
PHP obtains the real IP address of a user.
/** Function for obtaining the user IP address */function getIp () {$ onlineip = ""; if (getenv ('http _ CLIENT_IP ') & strcasecmp (getenv ('http _ CLIENT_IP '), 'Unknown') {$ onlineip = getenv ('http _
$ _ SERVER parameter HTTP_X_FORWARDED_FOR & amp; REMOTE_ADDR and get IP address. 1. REMOTE_ADDR: IP address of the user's computer on the current page. HTTP_X_FORWARDED_FOR: view the gateway of the user's computer on the current page. HTTP_CLIENT_IP:
Generally, $ _ SERVER [is used to obtain the user IP address $ _ SERVER ['remote _ ADDR,
However, if a reverse proxy is used, REMOTE_ADDR in the HTTP header is not the user's address, but the address of the previous proxy.
After my research, there
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.