It is used to display error information and success information. In fact, you can also directly echo the error information. Here I just want to see the highlights of my error information page and define a function for page output.
CopyCode The Code
1. php connects to the database
$ Dbhost = 'localhost ';$ Dbuser = 'root'; // your MySQL user name$ Dbpass = '000000'; // your MySQL password$ Dbname = 'data'; // your MySQL Database Name
// Connect to the local database$ Globals ["conn"] =
Program 1. It is responsible for randomly extracting data from the dictionary and writing a new file. (1.php)
CopyCode The Code is as follows: /* Extract random values from dictionary files */
$ File1 = "./words. DIC ";$ File2 =
The database stores hundreds of thousands of IP records. The record set is as follows:
+ ---------- + ------------ + --------- + -------- +| Ip_begin | ip_end | country_id | prov_id | city_id | isp_id | netbar |+ ---------- + ------------ + ------
On the other hand, sometimes you can use a simple line
Code To solve a problem.
The following are some cool features that you may not have noticed:
Use the ip2long () and long2ip () functions to convert an IP address into an integer and store it
In fact, it is very easy for PHP to decompress gzip. You can use the built-in gzdecode function, but it is a pity that I have been configured for half a day and cannot support the gzdecode function, so I have to work around it:
CopyCode The Code is
1. returns the file extension.Function getformat ($ file){$ Ext = strrchr ($ file ,".");$ Format = strtolower ($ ext );Return $ format;}
2. format the variable$ Num = 1;Printf ("% 04d", $ num );?>
3. php redirection webpage// For example,
$ _ Server ['php _ Self '] # File Name of the script being executed, which is related to document root.$ _ Server ['argv'] # parameters passed to the script.$ _ Server ['argc '] # include and pass Program Number of command line parameters (if
Match double-byte characters (including Chinese characters): [^ \ x00-\ xFF]
Application: Calculate the length of a string (two-byte length Meter 2, ASCII character meter 1)
String. Prototype. Len = function () {return this. Replace ([^ \ x00-\
Multiple Functions use the same name, but the parameter table, that is, the number of parameters or (and) data types can be different. Although the method name is the same during the call, however, the corresponding function can be automatically
Include_once is similar to require_once. It is used to check whether the contained file has been included. If so, it will not be executed. Otherwise, it will be included again. the reason for this is that if you have clarified include and require.
But we can replace it with regular expressions:
CopyCodeThe Code is as follows: Function dhtmlspecialchars ($ string ){
If (is_array ($ string )){
Foreach ($ string as $ key => $ Val ){
$ String [$ key] = dhtmlspecialchars ($ Val );
}
} Else {
Developed for cd2sc.com Website Functions,
Code It is original to me and the generation speed is average.
(For a well-known reason, the data field name involved in the database has been changed, and the parameter filtering is removed for the sake
Enterprise websites require at least one virtual host. However, OA, finance ...... These internal systems are hard to say.
Code And the database to people, write a description, let them follow the instructions to configure the environment, install
The complete
Program You can modify the specific application.
The example I provided here is very simple. In fact, many applications can be shown in this example. For example, hiding a real URL ...... Hey, let's analyze it by yourself.
Create a
A simple decryption is written for eval. This principle is very useful. Write it down here.
CopyCode The Code is as follows: /*
Author: zhiwushan
Data: 20080411
*/
// Encrypted File Content
$ A ="
Eval (gzinflate (str_rot13 (base64_decode
1. array_shift () removes the first unit of the array and returns the result. This is convenient for the first unit of the array to be processed independently.
CopyCode The Code is as follows: $ Tmparray = array ("1", "2", "3", "4 ");
$ Tmparray
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