PHPÊý¾Ý½á¹¹——ðÅÝÅÅÐòÓë¿ìËÙÅÅÐòµÄ±È½Ï
//ðÅÝÅÅÐò£¨Êý×éÖÐʵÏÖ£©
function bubble_sort($arr) {
$cnt = count($arr);
if($cnt<=0) return false;
for($i=0; $i<$cnt;$i++) {
for($j=$cnt-1; $j>$i;$j--) {
if($arr[$j]<$arr[$j-1]) {
$tmp = $arr[$j];
$arr[$j] = $arr[$j-1];
$arr[$j-1]=$tmp;
}
}
}
return $arr;
}
//¿ìËÙÅÅÐò£¨Êý×éÅÅÐò£©
function quicksort($arr) {
if(count($arr)<=1) return $arr;
$key = $arr[0];
$left_arr = array();
$right_arr = array();//н¨Ò»¸öÊý×é
for($i=1; $i<count($arr); $i++) {
if($arr[$i]<$key) {
$left_arr[] = $arr[$i];
} else {
$right_arr[] = $arr[$i];
}
}
$left_arr = quicksort($left_arr);
$right_arr = quicksort($right_arr);
return array_merge($left_arr,array($key),$right_arr);
}
for($i=0;$i<10000;$i++) {//²âÊÔÊý×é
$arr1[$i] = rand(0,10000);
}
$time_start = explode(" ",microtime());
bubble_sort($arr1);
$time_end = explode(" ", microtime());
echo "ðÅÝÅÅÐò·¨ËùÐèÒªµÄʱ¼ä:";
echo ($time_end[0]+$time_end[1] - $time_start[0]-$time_start[1])."<br>";//²âÊÔðÅÝÅÅÐò·¨ËùÐèÒªµÄʱ¼ä
echo '----------------------------------'.'<br>';
$time_start = explode(" ",microtime());
quicksort($arr1);
$time_end = explode(" ", microtime());
echo "¿ìËÙÅÅÐò·¨ËùÐèÒªµÄʱ¼ä:";
echo ($time_end[0]+$time_end[1] - $time_start[0]-$time_start[1])."<br>";//²âÊÔ¿ìËÙÅÅÐò·¨ËùÐèÒªµÄʱ¼ä
echo '-------------------------------------'."<br>";
$time_start = explode(" ",microtime());
sort($arr1);//phpÄÚÖöÔÊý×éÅÅÐòº¯Êý
$time_end = explode(" ", microtime());
echo "PHPÄÚÖú¯ÊýÅÅÐò·¨ËùÐèÒªµÄʱ¼ä:";
echo ($time_end[0]+$time_end[1] - $time_start[0]-$time_start[1])."<br>";//²âÊÔPHPÄÚÖú¯ÊýÅÅÐò·¨ËùÐèÒªµÄʱ¼ä
²âÊÔ½á¹û£º
ðÅÝÅÅÐò·¨ËùÐèÒªµÄʱ¼ä:22.864297151566
----------------------------------
¿ìËÙÅÅÐò·¨ËùÐèÒªµÄʱ¼ä:0.22899389266968
--------
Ïà¹ØÎĵµ£º
˵µ½¼Æ»®ÈÎÎñ´ó¼Ò¿ÉÄܶ¼Ïëµ½ÓÃcrontabÀ´ÊµÏÖ¡£¿ÉÊDz¢²»ÊÇËùÓÐÈ˶¼ÊÇʹÓÃlinuxϵͳ£¬Ò²²»ÊÇËùÓÐÈ˶¼ÓжÀÁ¢·þÎñÆ÷¡£ÕâʱºòÈçºÎÓÃphpÀ´
ʵÏּƻ®ÈÎÎñÄØ¡£
º¯Êý- ignore_user_abort()
£¬
Õâ¸öº¯Êý¿ÉÒÔ°ïÖúÎÒÃÇʵÏÖÏñlinuxÖеÄcronÒ»ÑùʵÏּƻ®ÈÎÎñ£¬ÏÂÃæÒ»ÆðÀ´¿´Ï¸ÃÈçºÎÀ´ÊµÏÖ¡£
¸Ãº¯Êý°´ÕÕ×ÖÃæÒâ˼¾ÍÊÇ“ºöÂÔÓû§Ö ......
<FORM METHOD=POST ACTION="#">
<INPUT TYPE="text" NAME="name">
<INPUT TYPE="submit" value="query" name="sub">
</FORM>
<?php
function getinitial($str)
{
$asc=ord(substr($str,0,1)); //ord()»ñÈ¡ASCII
if ($asc<160) //·ÇÖÐÎÄ
{
if ($asc>=48 ......
ÔÚPHPÖÐʹÓÃÍ·Îļþ£¬»áÉæ¼°Á½¸öº¯Êý£ºinclude()ºÍrequire()¡£ÕâÁ½¸öº¯Êý²î±ðºÜС£¬È´ºÜÖØÒª£¬ËùÒÔÎÒÃÇÒªÈÏÕæÑо¿Ò»Ï¡£
require()º¯Êý¹¤×÷·½Ê½ÓëXSSIÏàÀàËÆ£»²»¹ÜÔÚ³ÌÐòµÄÄĸö²¿·ÖʹÓÃÁËÕâ¸öº¯Êý£¬Ö»ÓгÌÐòÒ»¿ªÊ¼ÔËÐУ¬Í·ÎļþµÄÄÚÈݾͱ»×÷Ϊ³ÌÐò±¾ÉíµÄÒ»²¿·ÖÀ´´¦
Àí¡£Òò´Ë£¬Èç¹ûÄúÔÚÒ»¸öÌõ¼þÅж¨Óï¾äÖÐʹÓÃÁËrequire()º¯Ê ......
½ñÌìÍ·ÄÔÒ»ÈÈ£¬Ïë¿´Ò»ÏÂÒ³ÃæÔÚÖ´ÐеĹý³ÌÖÐÕ¼ÓÃÁ˶àÉÙÄڴ棬ÎÒÒ²²»ÖªµÀÕâÑù×öµÄÄ¿µÄÊÇʲô£¬¿ÉÄÜÊdzöÓÚÎҵĹßÐÔ˼ά°É¡£²»¹ýÕâÑù×öÒ²²»ÊÇÍêȫûÓã¬
Äã¿ÉÒÔÇå³þµÄÖªµÀÄÄÐ©Ò³ÃæÕ¼ÓõÄÄÚ´æ±È½Ï¶à£¬ÌرðÊǶÔÓÚʹÓù²ÓÃÖ÷»úµÄÍøÕ¾£¬Ò»°ã¿Õ¼äÉ̶¼»áÏÞÖÆÃ¿¸öÍøÕ¾µÄ×ÊÔ´Õ¼ÓÃÇé¿öµÄ£¨°üÀ¨cpuºÍÄڴ棩¡£ÍòÒ»ÔÚÎÒ
ÃDz»ÖªµÀµÄÇé¿öÏ£ ......
<?php
//GB2312µÄEncode
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
/*ÖØµãÁ˽âstrtotime()º¯Êý
1¡¢strftime±Ètime()ºÃÓ㬿ÉÒÔÖ±½Ó°Ñ³£ÓõĒ2010-02-03‘ת³Éʱ¼ä´Á¡£
2¡¢date( ......