Ò׽ؽØÍ¼Èí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö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 ·¢ËÍ Email


< ?php   
require("mail/class.phpmailer.php");//µ÷Óà  
$mail = new PHPMailer();//ʵÀý»¯phpmailer   
$address = "mailxi@126.com";//½ÓÊÕÓʼþµÄÓÊÏä   
$mail->IsSMTP(); // ÉèÖ÷¢ËÍÓʼþµÄЭÒ飺SMTP   
......

PHP³£ÓÃ×Ö·û´®º¯ÊýÊÕ¼¯£¨60¸ö£©

1¡¢AddcSlashes ×Ö·û´®¼ÓÈ뷴бÏß
Óï·¨£ºstring addcslashes(string str,string charlist);
2¡¢AddSlashes ×Ö·û´®¼ÓÈ뷴бÏß
Óï·¨£ºstring addslashes(string str);
ÔÚÌØ¶¨µÄ×Ö·ûǰ¼Ó·´Ð±Ïߣº'¡¢"¡¢\¡¢NULL
3¡¢bin2hex ½«¶þ½øÎ»×ª³ÉÊ®Áù½øÎ»
Óï·¨£ºstring bin2hex(string str);
4¡¢Chop È¥³ýÁ¬Ðø¿Õ°×,ͬrtrim()
Óï· ......

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

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

ʲôÊÇPHPÀàºÍÀàµÄ¶ÔÏó(PHPµÄÀà¼ò½é)

 
ÀࣨClass£©£ºÊÇһЩ±äÁ¿ÓëһЩʹÓÃÕâЩ±äÁ¿µÄº¯ÊýµÄ¼¯ºÏ¡£
¿É¼òµ¥Àí½âΪº¯ÊýºÍ±äÁ¿µÄ¼¯ºÏ£¬»ò±äÁ¿ºÍº¯ÊýµÄ¶¨ÒåµÄ¼¯ºÏ¡£
Óï·¨ÊÇ£º
class Class_name //ϰ¹ßÉÏÀàµÄµÚÒ»¸ö×Ö·ûΪ´óд£¬²¢ÇÒ±ØÐë·ûºÏ±äÁ¿µÄÃüÃû¹æÔò¡£
{
//º¯ÊýÓë±äÁ¿µÄ¼¯ºÏ(һЩ±äÁ¿(Àà³ÉÔ±)ºÍº¯Êý(ÐÐΪ·½·¨)µÄ¶¨Òå)¡£
}
Êý¾Ý³ÉÔ±(±äÁ¿)ÔÚÀ ......

php ÀàµÄʹÓÃ

Óû§¶¨ÒåµÄÀ࣬ҲÊÇѧºÃ PHP Ëù±Ø±¸µÄÌõ¼þÖ®Ò»¡£
¶ø PHP µÄÀ࣬ºÍÆäËüµÄÃæÏò¶ÔÏóÓïÑÔ±È½ÏÆðÀ´£¬»¹ËãÂùµ¥´¿µÄ¡£
PHP Ö»ÓÐÀà±ð (class)¡¢·½·¨ (method)¡¢ÊôÐÔ¡¢ÒÔ¼°µ¥Ò»¼Ì³Ð (extensions) µÈ¡£
¶Ô²»Ï°¹ßʹÓà C++¡¢Java¡¢Delphi µÈÃæÏò¶ÔÏóÓïÑÔÀ´¿ª·¢³ÌÐòµÄÓû§£¬²»·ÁÏÈÔĶÁÒ»ÏÂÓйØÃæÏò¶ÔÏó¸ÅÄîµÄÊ飬ÏàÐÅ¿ÉÒÔ´øÀ´Ðí¶àµÄÊÕ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ