First create a conn.php file to link the database
Copy CodeThe code is as follows:
$link = mysql_connect ("Mysql_host", "Mysql_user", "Mysql_password") or Die ("Could Not connect:". Mysql_error ());
mysql_query ("Set names UTF8");
mysql_select_db ("
Recently, the string is often used to match and replace the operation, before generally using str_replace or preg_replace, it is said that the STRTR efficiency is good, so a comparison:
Copy CodeThe code is as follows:
$i = 0;
$t = Microtime (true);
Copy CodeThe code is as follows:
/**
* Remove HTML tags
*
* @access Public
* @param string str
* @return String
*
*/
function deletehtml ($STR) {
$str = Trim ($STR); Clear spaces on both sides of a string
$str = Strip_tags ($str, "
"); Use PHP's own
"Verbose error":HTTP Error 500.0-internal Server error
C:\Program the files\php\php-cgi.exe-fastcgi process exceeded the configured request timeout period
"Environment":php + IIS7.5
Workaround:
Method
The simplest way is to add the following code directly to the PHP program code:
Copy the Code code as follows: Error_reporting (e_all^e_notice^e_warning);
You can turn off all notice and warning levels of errors.
Put this statement in your script's
deep parsing of server variable $_server:
1, $_session[' php_self ')--Gets the file name of the currently executing script
2, $_server[' Server_protocol ')--the name and version of the communication protocol when the page is requested. For example,
A few days ago began to run a data list, list needs to provide user name, whether there is a mobile phone number, whether there is a mailbox, user list I easily get to, but, the user list has more than 2000w, and to detect whether the user has a
1, start memcache common parameters
Copy CodeThe code is as follows:
-P
Listening TCP port (default: 11211)
-U
UDP Listening Port (default: 11211, 0 o'clock off)
-D runs as daemon
-U
Run an account running memcached non-root user
One, using the keyboard response, without refreshing this page to verify that the form input is legitimateThe user triggers a response event through the onkeydown and onkeyup events. The usage method is similar to the onclick event. OnKeyDown
If you need a friend, refer to it.
Copy CodeThe code is as follows:
/**
* Imitation QQ Verification Code
*/
Session Save Path
$sessSavePath = DirName (__file__). " /.. /data/sessions/";
if (is_writeable ($sessSavePath) && is_readable
A function that calculates the run time of a PHP page.
Copy CodeThe code is as follows:
/*
@ Calculate PHP program run time
*/
function Microtime_float ()
{
List ($usec, $sec) = Explode ("", Microtime ());
return (float) $usec + (float)
Recently used Phpcms V9 two times to develop a person site, before using 2008 has a more comfortable keyword all show out function, and v9 the keyword list function added to the search, if search a keyword will automatically generate an increase to
Copy CodeThe code is as follows:
Simple example
$html = file_get_html (' http://www.google.com/'); Get html$dom = new Simple_html_dom (); New Simple_html_dom Object $dom->load ($html)//load html//Find All images foreach ($dom->find (' img ') as $
Here only to show the design ideas, specific security issues, whether synchronization updates, etc. can be modified according to specific needs:Before people commonly used PHP paging technology, usually need to count the total number of information
PHP prevents the form from repeating the instance submission:
Copy CodeThe code is as follows:
Session_Start ();
$_session[' fsess ']= ($_session[' fsess '])? $_session[' Fsess ']:time ();
?>
Prevent forms from repeating
Copy the Code code as follows:
$t 1 = microtime (true);
// ... Execute code ...
$t 2 = Microtime (true);
Echo ' time-consuming '. Round ($t 2-$t 1,3). ' Seconds ';
simply say it. Microtime () If a true argument is taken, the return will be a
When I wrote PHP today, I found that $_post["arr" could not get an array of the parameters arr, record it.
For example, the following forms are required for submission:
Copy CodeThe code is as follows:
Use $_post["arr"]
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