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

php¶àÏß³ÌÉÏÏÂÎÄÖа²È«Ð´Îļþ

Ìṩһ¸öphp¶àÏß³ÌÉÏÏÂÎÄÖа²È«Ð´ÎļþµÄʵÏÖ·½·¨¡£Õâ¸öʵÏÖûÓÐʹÓÃphp µÄfile lock»úÖÆ£¬Ê¹ÓõÄÊÇÁÙʱÎļþ»úÖÆ¡£¶àÏß³ÌÖеĸ÷¸öÏ̶߳¼ÊǶԸ÷×Ô£¨Ã¿¸öÏ̶߳ÀÕ¼Ò»¸ö£©µÄÁÙʱÎļþд£¬È»ºóÔÙͬ²½µ½Ô­ÎļþÖС£
<?php
/**
* @usage: used to offer safe file write operation in multiple threads context, arbitory file type
* @author: Rocky Zhang
* @time: Nov. 11 2009
* @demo[0]: $handler = mfopen($file, 'a+');
*        mfwrite($handler, $str);
*/
function mfopen($file, $mode='w+') {
    $tempfile = generateTempfile('./tempdir', $file);
    preg_match('/b/i', $mode) || ($mode .= 'b'); // 'b' is recommended
    if (preg_match('/\w|a/i', $mode) && !is_writable($file)) {
        exit("{$file} is not writable!");
    }
    $filemtime = $filemtime2 = 0;
    $tempdir = dirname($tempfile);
    is_dir($tempdir) || mkdir($tempdir, 0777);
    do { // do-while used to avoid modify in a long time copy
        clearstatcache();
        $filemtime = filemtime($file);
        copy($file, $tempfile);
        $filemtime2 = filemtime($file);
    } while ( ($filemtime2 - $filemtime) != 0 );
    if (!$handler = fopen($tempfile, $mode)) {
        exit('Fail on opening tempfile, write authentication is must on temporary dir!');
    }
    return array(0=>$handler, 1=>$filemtime, 2=>$file, 3=>$tempfile, 4=>$mode);
}
// I do think that this function should be optimized further
function mfwrite(&$handler, $str='') {
    if (strlen($str) > 0) {
        $num = fwrite($handler[0], $str);
      


Ïà¹ØÎĵµ£º

phpÖÐheader()º¯ÊýʹÓÃ˵Ã÷

eader()º¯ÊýʹÓÃ˵Ã÷£º  
 
Ò»¡¢×÷Ó㺠 
~~~~~~~~~  
       PHPÖ»ÊÇÒÔHTTPЭÒ齫HTMLÎĵµµÄ±êÍ·Ë͵½ä¯ÀÀÆ÷£¬¸æËßä¯ÀÀÆ÷¾ßÌåÔõô´¦ÀíÕâ¸öÒ³Ãæ£¬ÖÁÓÚ´«Ë͵ÄÄÚÈÝÔòÐèÒªÊìϤһÏÂHTTPЭÒéÁË£¬ÓëPHPÎÞ¹ØÁË£¬¿É²ÎÕÕhttp://www.w3.org/Protocols/rfc2616/rfc2616¡£  
  & ......

APC(Alternative PHP Cache)

APCÊÇÒ»ÖÖphpµÄ»º´æ½â¾ö·½°¸,ĿǰÒÔpecl·½Ê½·¢²¼,ÓÐÏûϢ˵½«»á³öÏÖÔÚphp6°æ±¾µÄÄÚºË.
Ò».°²×°·½·¨
1)´Óhttp://pecl.php.net/package/apcÏÂÔØÏàÓ¦°æ±¾
2)½âѹ
3)½øÈëÔ´ÂëĿ¼
4)Ö´ÐÐphp°²×°Ä¿Â¼ÏµÄbin/phpize
5)./configure --enable-apc --enable-apc-mmap --with-apxs=path-to-apache/bin/apxs --with-php-config=p ......

phpÖеĵ±Ç°ÍøÖ·ºÍ¸ù·¾¶

µ±Ç°ÍøÖ·ÊÇä¯ÀÀÆ÷ÀíÏÔʾµÄÍøÖ·£¬ÊÇÓû§¿´µ½µÄ¡£
¸ù·¾¶ÊÇphpÎļþÔÚ·þÎñÆ÷ÉϵÄ·¾¶£¬ÊÇÕæÊµµÄÎļþ·¾¶¡£
(ÓëjavaÊDz»Ò»ÑùµÄ)
Èç¹ûÓжà²ãincludeÓï¾ä£¬±ØÐëÓøù·¾¶£¬·ñÔò³ö´í¡£
Ìá½»±íµ¥Ê±ÒªÌá½»µ½µ±Ç°ÍøÖ·µÄÏà¶Ô»òÕß¾ø¶ÔµÄÍøÖ·ÀïÃæ¡£
---------------------------------------------------------------------
Ò»¸öÊÇÍ ......

PHPÀàµÄÊôÐÔ·ÃÎÊÆ÷·½·¨

µ±´æÈ¡Ò»¸öÀàµÄ²»´æÔÚµÄÊôÐÔʱ£¬½âÎöÆ÷»áÅжÏÊÇ·ñÓÐÒÔÏÂÁ½¸öÊôÐÔ·ÃÎÊÆ÷·½·¨£º
__getºÍ__set¡£
Èç¹ûÓУ¬Ôò»á×Ô¶¯µ÷ÓÃÕâЩ·½·¨¡£Í¨¹ýÊôÐÔ·ÃÎÊÆ÷·½·¨¿ÉÒÔ¿ØÖƶÔÀàÊôÐԵķÃÎÊ£¬ÒÔʵÏÖ¶ÔÒª±£´æµÄÊý¾Ý½øÐмì²é£¬´Ó¶øÈ·±£ÊôÐÔÖµÓÐÒâÒåµÄÊý¾Ý¡£__get·½·¨Ö»ÓÐÒ»¸ö²ÎÊý£¬ÓÃÓÚ´«µÝÊôÐÔµÄÃû³Æ¡£__set·½·¨ÓÐÁ½¸ö²ÎÊý£¬·Ö±ðÓÃÓÚ´«µÝÊôÐÔ ......

PHP¿ª·¢»·¾³ÅäÖùý³ÌÏê½â

ÓÉÓÚÄêǰ°Ñ¹¤×÷È·ÈÏÏÂÀ´ÁË£¬ÓÚÊÇ×¼±¸ÀûÓÃ׫д±ÏÒµÂÛÎÄµÄÆÚ¼äѧϰһÏÂPHPµÄ¿ª·¢£¬ÈκÎÒ»ÃÅÓïÑÔµÄѧϰ¹ý³Ì£¬µÚÒ»²½¶¼ÊÇ¿ª·¢»·¾³µÄ³É¹¦ÅäÖã¬ÓÚÊÇÎÒ»¨ÁËÒ»ÉÏÎçʱ¼ä°Ñ»·¾³´î½¨³É¹¦¡£
PHP¿ª·¢»·¾³ÅäÖùý³ÌÏê½â
±¾´ÎÅäÖÃÖ÷ÒªÕë¶ÔÓÚWindows XPϵÄÅäÖð²×°£¬ÖÁÓÚLinuxϵÄÅäÖð²×°½«ÔÚÒÔºó¸øÓè²¹³ä¡£
Ò»¡¢ËùÐèÈí¼þ
Windows XP ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ