Ò׽ؽØÍ¼Èí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

php¶àÏß³Ì

ÒÔ϶¼ÊÇ×ªÔØ£¬ ¼òµ¥ËµÏ£¬ phpÊDz»Ö§³Ö¶àÏ̵߳ġ£¡£¡£¡£
PHPÓïÑÔ±¾ÉíÊDz»Ö§³Ö¶àÏ̵߳Ä. ×ܽáÁËÒ»ÏÂÍøÉϹØÓÚPHPÄ£Äâ¶àÏ̵߳ķ½·¨, ×ܵÄÀ´Ëµ, ¶¼ÊÇÀûÓÃÁËPHPµÄºÃ»ï°éÃDZ¾ÉíËù¾ßÓеĶàÏß³ÌÄÜÁ¦. PHPµÄºÃ»ï°éÖ¸µÄ¾ÍÊÇLINUXºÍAPACHEÀ², LAMPÂï.
  ÁíÍâ, ¼ÈÈ»ÊÇÄ£ÄâµÄ, ¾Í²»ÊÇÕæÕýµÄ¶àÏß³Ì. ÆäʵֻÊÇ¶à½ø³Ì. ½ø³ÌºÍÏß³ÌÊÇÁ½¸ö²»Í¬µÄ¸ÅÄî. ºÃÁË, ÒÔÏ·½·¨¶¼ÊÇ´ÓÍøÉÏÕÒÀ´µÄ.
  1. ÀûÓÃLINUX²Ù×÷ϵͳ
<?php
for ($i=0;$i<10;$i++) {
  echo $i;
  sleep(5);
}
?>
  ÉÏÃæ´æ³Étest.php, È»ºóдһ¶ÎSHELL´úÂë
#!/bin/bash
for i in 1 2 3 4 5 6 7 8 9 10
do
  php -q test.php &
done
  2. ÀûÓÃfork×Ó½ø³Ì(ÆäʵͬÑùÊÇÀûÓÃLINUX²Ù×÷ϵͳ)
<?php
declare(ticks=1);
$bWaitFlag = FALSE; /// ÊÇ·ñµÈ´ý½ø³Ì½áÊø
$intNum = 10;      /// ½ø³Ì×ÜÊý
$pids = array();    /// ½ø³ÌPIDÊý×é
echo ("Startn");
for($i = 0; $i < $intNum; $i++) {
$pids[$i] = pcntl_fork();/// ²úÉú×Ó½ø³Ì£¬¶øÇÒ´Óµ±Ç°ÐÐ֮ϿªÊÔÔËÐдúÂ룬¶øÇÒ²»¼Ì³Ð¸¸½ø³ÌµÄÊý¾ÝÐÅÏ¢
if(!$pids[$i]) {
  // ×Ó½ø³Ì½ø³Ì´úÂë¶Î_Start
  $str="";
  sleep(5+$i);
  for ($j=0;$j<$i;$j++) {$str.="*";}
  echo "$i -> " . time() . " $str n";
  exit();
  // ×Ó½ø³Ì½ø³Ì´úÂë¶Î_End
}
}
if ($bWaitFlag)
{
for($i = 0; $i < $intNum; $i++) {
  pcntl_waitpid($pids[$i], $status, WUNTRACED);
  echo "wait $i -> " . time() . "n";
}
}
echo ("Endn");
?>
  3. ÀûÓÃWEB SERVER, PHP²»Ö§³Ö¶àÏß³Ì, APACHE¿ÉÊÇÖ§³ÖµÄ, ºÇºÇ.
  ¼ÙÉèÎÒÃÇÏÖÔÚÔËÐеÄÊÇa.phpÕâ¸öÎĵµ. µ«ÊÇÎÒÔÚ³ÌʽÖÐÓÖÇëÇóWEB·þÎñÆ÷ÔËÐÐÁíÒ»¸öb.php
  ÄÇôÕâÁ½¸öÎĵµ½«ÊÇͬʱִÐеÄ.
<?php
function runThread()
{
$fp = fsockopen('localhost', 80, $errno, $errmsg);
fputs($fp, "GET /a.php?act=brnrn");
fclose($fp);
}
function a()
{
$fp = fopen('result_a.log', 'w');
fputs($fp, 'Set in ' . Date('h:i:s', time()) . (double)microtime() . "rn");
fclose($fp);
}
function b()
{
$fp = fopen('result_b.log', 'w');
fputs($fp, 'Set in ' . Date('h:i:s', time()) . (


Ïà¹ØÎĵµ£º

php js ¶¯Ì¬½ø¶ÈÌõ

<?php
//×¢Ò⣬Èç¹ûÊǰ²È«Ä£Ê½£¬Çë²»Òª´ò¿ª£¬Èç¹û²»Êǰ²È«Ä£Ê½£¬Õâ¸öÑ¡Ïî¿ÉÒÔ´ò¿ª
//set_time_limit(0);
for ($i = 0; $i < 500; $i++) {
$users[] = 'Tom_' . $i;
}//end for
$width = 500; //ÏÔʾµÄ½ø¶ÈÌõ³¤¶È£¬µ¥Î» px
$total = count($users); //×ܹ²ÐèÒª²Ù×÷µÄ¼Ç ......

PHP ÖÐ$_SERVERµÄ²ÎÊýºÍÓ÷¨ËµÃ÷


$_SERVER['PHP_SELF']  #µ±Ç°ÕýÔÚÖ´Ðнű¾µÄÎļþÃû£¬Óëdocument rootÏà¹Ø¡£
$_SERVER['argv']  #´«µÝ¸ø¸Ã½Å±¾µÄ²ÎÊý
$_SERVER['argc']  #°üº¬´«µÝ¸ø³ÌÐòµÄÃüÁîÐвÎÊýµÄ¸öÊý£¨Èç¹ûÔËÐÐÔÚÃüÁîÐÐģʽ£©¡£
$_SERVER['GATEWAY_INTERFACE']  #·þÎñÆ÷ʹÓÃµÄ CGI ¹æ·¶µÄ°æ±¾¡£ÀýÈ磬& ......

PHP ·µ»ØÖµ

Àý×Ó. return() º¯ÊýµÄÓ÷¨
<?php
function square ($num)
{
    return $num * $num;
}
echo square (4);   // outputs '16'.
?>
º¯Êý²»ÄÜ·µ»Ø¶à¸öÖµ£¬µ«ÎªÁË»ñµÃ¼òµ¥µÄ½á¹û£¬¿ÉÒÔ·µ»ØÒ»¸öÁÐ±í¡£
Àý×Ó. ·µ»ØÒ»¸öÊý×éÒԵõ½¶à¸ö·µ»ØÖµ
<?php
function small_numbe ......

PHP substr() º¯Êý

ת×Ô:http://www.w3school.com.cn/php/func_string_substr.asp
PHP substr() º¯Êý
PHP String º¯Êý
¶¨ÒåºÍÓ÷¨
substr() º¯Êý·µ»Ø×Ö·û´®µÄÒ»²¿·Ö¡£
Óï·¨
substr(string,start,length)
²ÎÊýÃèÊö
string
±ØÐè¡£¹æ¶¨Òª·µ»ØÆäÖÐÒ»²¿·ÖµÄ×Ö·û´®¡£
start
±ØÐè¡£¹æ¶¨ÔÚ×Ö·û´®µÄºÎ´¦¿ªÊ¼¡£
ÕýÊý - ÔÚ×Ö·û´®µÄÖ¸¶¨Î»Öÿª ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ