ÓÐûÓа취ÔÚphpÖÐʵÏÖ¶àÏß³ÌÄØ£¿
£¨×ª£©ÎÊÌ⣺
ÓÐûÓа취ÔÚphpÖÐʵÏÖ¶àÏß³ÌÄØ£¿
¼ÙÉèÄãÕýÔÚдһ¸ö»ùÓÚ¶ą̀·þÎñÆ÷µÄphpÓ¦Óã¬ÀíÏëµÄÇé¿öʱͬʱÏò¶ą̀·þÎñÆ÷·¢ËÍÇëÇ󣬶ø²»ÊÇһ̨½Óһ̨¡£
¿ÉÒÔʵÏÖÂð£¿
»Ø´ð£º
µ±ÓÐÈËÏëҪʵÏÖ²¢·¢¹¦ÄÜʱ£¬ËûÃÇͨ³£»áÏëµ½ÓÃfork»òÕßspawn threads£¬µ«Êǵ±ËûÃÇ·¢ÏÖphp²»Ö§³Ö¶àÏ̵߳Äʱºò£¬´ó¸Å»áת»»Ë¼Â·È¥ÓÃһЩ²»¹»ºÃµÄÓïÑÔ£¬±ÈÈçperl¡£
ÆäʵµÄÊÇ´ó¶àÊýÇé¿öÏ£¬Äã´ó¿É²»±ØʹÓÃfork»òÕßỊ̈߳¬²¢ÇÒÄã»áµÃµ½±ÈÓÃfork»òthread¸üºÃµÄÐÔÄÜ¡£
¼ÙÉèÄãÒª½¨Á¢Ò»¸ö·þÎñÀ´¼ì²éÕýÔÚÔËÐеÄn̨·þÎñÆ÷£¬ÒÔÈ·¶¨ËûÃÇ»¹ÔÚÕý³£ÔËת¡£Äã¿ÉÄÜ»áдÏÂÃæÕâÑùµÄ´úÂ룺
$hosts = array("host1.sample.com", "host2.sample.com", "host3.sample.com");
$timeout = 15;
$status = array();
foreach ($hosts as $host) {
$errno = 0;
$errstr = "";
$s = fsockopen($host, 80, $errno, $errstr, $timeout);
if ($s) {
$status[$host] = "Connectedn";
fwrite($s, "HEAD / HTTP/1.0rnHost: $hostrnrn");
do {
$data = fread($s, 8192);
if (strlen($data) == 0) {
break;
}
$status[$host] .= $data;
} while (true);
fclose($s);
} else {
$status[$host] = "Connection failed: $errno $errstrn";
}
}
print_r($status);
?>
ËüÔËÐеĺܺ㬵«ÊÇÔÚfsockopen()·ÖÎöÍêhostname²¢ÇÒ½¨Á¢Ò»¸ö³É¹¦µÄÁ¬½Ó£¨»òÕßÑÓʱ$timeoutÃ룩֮ǰ£¬À©³äÕâ¶Î´úÂëÀ´¹ÜÀí´óÁ¿·þÎñÆ÷½«ºÄ·ÑºÜ³¤Ê±¼ä¡£
Òò´ËÎÒÃDZØÐë·ÅÆúÕâ¶Î´úÂ룻ÎÒÃÇ¿ÉÒÔ½¨Á¢Òì²½Á¬½Ó-²»ÐèÒªµÈ´ýfsockopen·µ»ØÁ¬½Ó״̬¡£PHPÈÔÈ»ÐèÒª½âÎöhostname£¨ËùÒÔÖ±½ÓʹÓÃip¸ü¼ÓÃ÷ÖÇ£©£¬²»¹ý½«ÔÚ´ò¿ªÒ»¸öÁ¬½ÓÖ®ºóÁ¢¿Ì·µ»Ø£¬¼Ì¶øÎÒÃǾͿÉÒÔÁ¬½ÓÏÂһ̨·þÎñÆ÷¡£
ÓÐÁ½ÖÖ·½·¨¿ÉÒÔʵÏÖ£»PHP5ÖпÉÒÔʹÓÃÐÂÔöµÄstream_socket_client()º¯ÊýÖ±½ÓÌæ»»µôfsocketopen()¡£PHP5֮ǰµÄ°æ±¾£¬ÄãÐèÒª×Ô¼º¶¯ÊÖ£¬ÓÃsocketsÀ©Õ¹½â¾öÎÊÌâ¡£
ÏÂÃæÊÇPHP5ÖеĽâ¾ö·½·¨£º
$hosts = array("host1.sample.com", "host2.sample.com", "host3.sample.com");
$timeout = 15;
$status = array();
$sockets = array();
/* Initiate connections to all the hosts simultaneously */
foreach ($hosts as $id => $host) {
$s = stream_socket_client("$host:80", $errno, $errstr, $timeout,
STREAM_CLIENT_ASYNC_CONNECT|STREAM_CLIENT_CONNECT);
if ($s) {
$sockets[$id] = $s;
$status[$id
Ïà¹ØÎĵµ£º
¡¡ÎÒÃÇ°ÑÏÂÔصÄÈý¸öÈí¼þ°ü·Åµ½/var/localĿ¼Ï£¨ÕâÊDZÊÕ߸öÈ˵ÄÏ°¹ß£©£¬ËüÃǶ¼ÊÇtar.gz°ü£¬¿ÉÒÔÓÃÃüÁîtar -xzpvf °üÃû£¬°ÑËüÃÇÔÚµ±Ç°Ä¿Â¼£¨/var/local/£©Öн⿪£º
cd /var/local
tar -xzpvf mysql-4.0.15.tar.gz
tar -xzpvf php-4.3.3.tar.gz
tar -xzpvf httpd-2.0.47.tar.gz
¡¡¡¡½â°üºó¿ÉÒÔ¿ªÊ¼½øÈëÕýʽ°²×°¡£ ......
ģʽÐÞÕý·û — ½â˵ÕýÔò±í´ïʽģʽÖÐʹÓõÄÐÞÕý·û
˵Ã÷
ÏÂÃæÁгöÁ˵±Ç°ÔÚ PCRE ÖпÉÄÜʹÓõÄÐÞÕý·û¡£À¨ºÅÖÐÊÇÕâЩÐÞÕý·ûµÄÄÚ²¿ PCRE Ãû¡£ÐÞÕý·ûÖеĿոñºÍ»»Ðб»ºöÂÔ£¬ÆäËü×Ö·û»áµ¼Ö´íÎó¡£
i (PCRE_CASELESS) Èç¹ûÉ趨´ËÐÞÕý·û£¬Ä£Ê½ÖеÄ×Ö·û½«Í¬Ê±Æ¥Åä´óСд×Öĸ¡£ m£¨PCRE_MULTILINE£© ĬÈÏÇé¿öÏ£¬PCR ......
¼òÊöÌâ(50·Ö)()
1¡¢ÓÃPHP´òÓ¡³öÇ°Ò»ÌìµÄʱ¼ä¸ñʽÊÇ2006-5-10 22:21:21(2·Ö)
echo date('Y-m-d H:i:s', strtotime('-1 day'));
»òÕß
$yesterday = time() - (24 * 60 * 60);
echo 'today:'.date('Y-m-d H:i:s')."\n";
echo 'yesterday:'. date('Y-m-d H:i:s', $yesterday)."\n";
2¡¢echo(),print(),print_r()µÄÇø±ð( ......
ÔÎijö×Ô£º http://www.hly1980.cn/archives/118.html
ÐèÒª·ÖÎöÈÕ־ʱtailÃüÁî¿ÉÊdz£ÐèÒªÓõ½µÄ£¬¿ÉϧphpÄÚ²¢Ã»ÓÐÌṩÀàËƵķ½·¨£¬ËùÒÔ×Ô¼ºÊµÏÖÁËÒ»¸ö¡£
µ÷Ó÷½Ê½Îªtail($filename, $rows)£¬Ã¿´ÎĬÈ϶ÁÈ¡1024×Ö½Ú×÷Ϊ»º³å£¬·µ»Ø×Ö·û´®Êý×飬ÎļþβµÄÐп¿Ç°£¨ÕâÀïµÄÐÐΪºÍtailÓÐËùÇø±ð£¬Èç¹ûÐèÒªÒÔÔÐò·µ»ØµÄÇë×ÔÐе÷ÓÃarr ......
µ±ÎÒÃÇÓÃWINDOWSËÑË÷ij°üº¬Ä³ÎÄ×ÖµÄÎļþʱ£¬¿ÉÒÔÔÚ“°üº¬ÎÄ×Ö”´¦ÌîÉÏËÑË÷´Ê¡£µ«ÊÇһЩ²»³£¼ûµÄºó׺ÃûÎļþWINDOWS²»»áËÑË÷£¬È磺£¬.log¡¢.dll¡¢.js¡¢.asp¡¢.xml¡¢.xsl¡¢.hta¡¢.css¡¢.wsh¡¢.cpp¡¢.c »ò .hµÈ¼°ÎÞºó׺ÃûµÄÎļþ¡£¶ÔÓÚÎҵȳÌÐò°®ºÃÕßÀ´ËµÊµÔÚÌ«²»·½±ãÁË£¬ËäÈ»ÓГÎı¾Ìæ»»´óʦ”µÈÈí¼þÄÜ×öÕ ......