How does php obtain the Client ip address?
Php obtains the Client ip address, which is simple and practical.
Function getOnlineIP (){
$ Cip = getenv ('HTTP _ CLIENT_IP ');
$ Xip = getenv ('HTTP _ X_FORWARDED_FOR ');
$ Rip = getenv ('remote _
PHP queries the complete MySQL database code
PHP queries the complete MySQL database code. When using this code, you must modify the user name and password in the connection statement.
$ Link = mysql_connect ('localhost', 'root', '000000') // The
List_to_tree of Thinkphp enables unlimited classification to list all nodesList_to_tree is very convenient to use. For more information, see the manual. Because I need to list all nodes at the same time when using it, I wrote a recursive function
Three major automatic versions in thinkPHP
Class UserModel extends Model {Protected $ _ validate = array (
// You also need to write the array below. An array is a validation rule.// Array ('verification field', 'verification rule', 'error message',
PHP uses JQueryJcrop to explain how to crop images,
We often see some websites with the image cutting function. You may think this function is gorgeous and mysterious! However, the jquery. Jcrop. min. js plug-in for image cropping will unveil the
Use PHP to cache database query results
Sometimes we want to reduce the number of queries to the database to improve the program performance, because the data is not changed frequently, but will not change for a long time. Therefore, each time we
We can see that sometimes the controller under the protected directory is used, and sometimes the controller in the module is used. how can this problem be solved, see the following analysis. the url path using the yii Framework is generally like
In the system, you can create an automatic number for a new file. For example, if the default file name of the new text file is "new text file .txt", the file name automatically changes when the new file is created: the new text file (2).txt, which
Use PHP to generate a single HTML document from the document data in the database. First, it is beneficial to search engines. Second, avoid exposing fields in the database to the address bar and give the code more securely:
Copy codeThe code is as
Huawei online storage has a straight-chain function, but it requires money. I have a Baidu network disk, but Baidu's external network disk chain cannot be directly used in the web page. Baidu can also have this function one day.
First Code: less
The saddslashes function is often used in the Discuze open-source project. here is a brief introduction to help you
// GPC filter, automatically escape special characters in $ _ GET, $ _ POST, and $ _ Cookies to prevent SQL injection attacks$ _ GET =
Php simulates the function code of the js function unescape. For more information, see.
Copy codeThe code is as follows:
Function unescape ($ str)
{
$ Ret = '';
$ Len = strlen ($ str );
For ($ I = 0; $ I {
If ($ str [$ I] = '%' & $ str [$ I
I have been touched by the page cache of phpcms over the past few days. The advantage is not much said. It is generally used on pages with a large number of database queries. it is not suitable for inserting, modifying, and deleting pages.
Here is a
Several methods to replace line breaks in PHP. For more information, see
First:Copy codeThe code is as follows:
? $ Str = "this is a test \ n ";$ Patten = array ("\ r \ n", "\ n", "\ r ");? // Replace \ r \ n first, check whether \ n exists, and
If you are idle, you can get the template function, which is rough. It mainly uses regular expressions to convert a template file (html file) into a php file to implement frontend and backend separation. this is the so-called mvc idea. I have read
Php full-arrangement recursive algorithm code. For more information, see
Algorithm principle
If P is used to represent the full arrangement of n elements, and Pi is used to represent the full arrangement of n elements that do not contain element I, (
PHP gets the file suffix. There are many ways to get the file extension. the following three methods are provided to get the file suffix. you can study it and the specific code will not be explained. Let's look at the code and select a method to
The following implementation code searches for tags from the database and formats the tags so that they are displayed based on the number of occurrences to connect to the database, the table storing the article contains the "Tag" field, which is
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