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);
Ïà¹ØÎĵµ£º
login¡£phpÌý˵ҪÓøöµÚÈý·½Ò³ÃæÀ´ÊµÏÖÌø×ª¡£ËµÊÇΪÁ˰²È«·½ÃæµÄ¿¼ÂÇ¡£ÎÒÔÙÏëÏë°É~
ÏȰѴúÂëÌù³öÀ´
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta h ......
AddSlashes: ×Ö·û´®¼ÓÈëбÏß¡£
bin2hex: ¶þ½øÎ»×ª³ÉÊ®Áù½øÎ»¡£
Chop: È¥³ýÁ¬Ðø¿Õ°×¡£
Chr: ·µ»ØÐòÊýÖµµÄ×Ö·û¡£
chunk_split: ½«×Ö·û´®·Ö³ÉС¶Î¡£
convert_cyr_string: ת»»¹Å˹À·ò×Ö·û´®³ÉÆäËü×Ö·û´®¡£
crypt: ½«×Ö·û´®Óà DES ±àÂë¼ÓÃÜ¡£
echo: Êä³ö×Ö·û´®¡£
explode: Çпª×Ö·û´®¡£
flush: Çå³öÊä³ö»º³åÇø¡£
get ......
< ?php
require("mail/class.phpmailer.php");//µ÷ÓÃ
$mail = new PHPMailer();//ʵÀý»¯phpmailer
$address = "mailxi@126.com";//½ÓÊÕÓʼþµÄÓÊÏä
$mail->IsSMTP(); // ÉèÖ÷¢ËÍÓʼþµÄÐÒ飺SMTP
......
µ±Ç°ÍøÖ·ÊÇä¯ÀÀÆ÷ÀíÏÔʾµÄÍøÖ·£¬ÊÇÓû§¿´µ½µÄ¡£
¸ù·¾¶ÊÇphpÎļþÔÚ·þÎñÆ÷ÉϵÄ·¾¶£¬ÊÇÕæÊµµÄÎļþ·¾¶¡£
(ÓëjavaÊDz»Ò»ÑùµÄ)
Èç¹ûÓжà²ãincludeÓï¾ä£¬±ØÐëÓøù·¾¶£¬·ñÔò³ö´í¡£
Ìá½»±íµ¥Ê±ÒªÌá½»µ½µ±Ç°ÍøÖ·µÄÏà¶Ô»òÕß¾ø¶ÔµÄÍøÖ·ÀïÃæ¡£
---------------------------------------------------------------------
Ò»¸öÊÇÍ ......
ÔÚ·ÃÎÊPHPÀàÖеijÉÔ±±äÁ¿»ò·½·¨Ê±£¬Èç¹û±»ÒýÓõıäÁ¿»òÕß·½·¨±»ÉùÃ÷³Éconst»òÕßstatic,ÄÇô¾Í±ØÐëʹÓòÙ×÷·û::,·´Ö®Èç¹û±»ÒýÓõıäÁ¿»òÕß·½·¨Ã»Óб»ÉùÃ÷³Éconst»òÕßstatic,ÄÇô¾Í±ØÐëʹÓòÙ×÷·û->¡£
ÁíÍ⣬Èç¹û´ÓÀàµÄÄÚ²¿·ÃÎÊconst»òÕßstatic±äÁ¿»òÕß·½·¨,ÄÇô¾Í±ØÐëʹÓÃ×ÔÒýÓõÄself£¬·´Ö®Èç¹û´ÓÀàµÄÄÚ²¿·ÃÎʲ»Îªcons ......