[PHP] practical functions 2 1. Generate random string functions
The code is as follows:
Function random ($ length ){$ Hash = @#@#;$ Chars =@# ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz @#;$ Max = strlen ($ chars)-1;Mt_srand
Favorite common PHP functions are recommended. Save the following content:
The code is as follows:
Function GetIP () {// obtain the IP addressIf ($ _ SERVER ["HTTP_X_FORWARDED_FOR"])$ Ip = $ _ SERVER ["HTTP_X_FORWARDED_FOR"];Else if ($ _ SERVER
Call Sina api based on the ip address to obtain the city name and convert it to pinyin. Function: 1. obtain the current IP address. 2. call Sina API to obtain the current city. 3. convert Chinese to pinyin and then jump. Copy the code as follows :?
I. no proxy server is used: REMOTE_ADDR your IPHTTP_VIA has no value or does not show HTTP_X_FORWARDED_FOR has no value or does not show 2. Transparent use
I. no proxy server is used:
REMOTE_ADDR = your IP address
HTTP_VIA = no value or no
Php code for obtaining the Internet IP address of the client. Leng Feng: both methods are available. The first method must be supported by the built-in curl, and the second method is more common. The second type is recommended. Method 1:
The PHP encryption and decryption function can be used to encrypt some useful strings and store them in the database. the Function uses base64 and MD5 encryption and decryption.
1. PHP encryption and decryption
The PHP encryption and decryption
Php ip address and IP address segment access restriction code. Read the php ip address and IP address segment access restriction code. several functions have been written, and the IP address blacklist is recorded in the library for ease of
Analysis of several PHP client IP addresses: no proxy server is used, transparent proxy server is used, normal anonymous proxy server is used, fraudulent proxy server is used, and high anonymous proxy server is used. In this article, we will
This article mainly introduces the use of PHP custom functions, interested in the reference of friends, I hope to be helpful to everyone.
1, take the client IP
function Getonlineip () { $strOnlineIp = ""; if (getenv (' http_client_ip ') &&
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 visitor's IP address
Obtain the visitor's IP address [PHP] code
Static public function getip ()
{
If (getenv ("HTTP_CLIENT_IP") & strcasecmp (getenv ("HTTP_CLIENT_IP"), "unknown "))
{
$ Ip =
This article describes how to share the php + curl IMG code. For more information, see // upload page code.
$ Url = "http: // 192.168.1.100/upload. php? Lang = cn "; # you can get the corresponding parameter $ file = $ path. '/'. $ Icon; // file
A php connection class to the mysql database
/*
* Filename: mysql database connection class
* Edit bbs.it-home.org
*/
Class mysql {
Private $ db_host; // database host
Private $ db_user;
This article mainly introduces common PHP functions and summarizes examples and usage of functions such as encryption and decryption, string operations, file operations, and SQL injection, PHP project development is very useful. if you need it, you
Code used in PHP to restrict access to IP segments and prohibit IP address submission forms. We only need to add the following code in feedback. php to judge. Note: The following is only an example code for php ip address restriction. if you want to
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.