PHP½«Ð¡Ð´¸Ä³É´óд½ð¶î
<?
error_reporting(2047);#±¨¸æËùÓзǷ¨µÄ´íÎó
ob_start();
function RMB ($RMB=0,$Format='') {
/*
*/
$RMB=@preg_Replace(
array('/([, ]|£¤|0$|)/','/(.){2,}/'),
array('','.'),
$RMB);
if(eregi("[^0-9.]",$RMB))return "·Ç·¨½ð¶î";
if($RMB==0)return "ÁãÔªÕû";
elseif($RMB>pow(10,12))return "½ð¶î±ØÐëСÓÚǧÒÚ";
$re = '';
$arr1 = array('Áã','Ò¼','·¡','Èþ','ËÁ','Îé','½','Æâ','°Æ','¾Á');
$arr2 = array('Ôª','ʰ','°Û','Ǫ','Íò','ʰ','°Û','Ǫ','ÒÚ','ʰ','°Û','Ǫ');
$arr3 = array('½Ç','·Ö','Àå','ºÁ');
$pre1 = count($arr2); #µ¥Î»¾«È·¶È precision
$pre2 = count($arr3); #СÊýλ¾«È·¶È precision
$arr = @explode(".",$RMB);#°´Ð¡ÊýµãÇиî½ð¶î
$len1 = @strlen($arr[0]); #ÕûÊý볤¶È
$len2 = @strlen($arr[1]); #СÊý볤¶È
for($i=0; $i<$len1 && $i<$pre1; $i++)
{
$bit =$arr[0][$len1-$i-1]; #µ±Ç°Î»Ð¡Ð´½ð¶î
$cn =$arr1[$bit]; #µ±Ç°Î»´óд½ð¶î
$unit =$arr2[$i];
#µ±Ç°Î»½ð¶îµ¥Î»
#Сд½ð¶îΪÁãµÄÇé¿ö
if($bit==0)
{
if(ereg('Ôª|Íò|ÒÚ',$unit))$re=$unit.$re;
else $re=$cn.$re;
}
#Сд½ð¶î·ÇÁãµÄÇé¿ö
else
{
$re=$cn.$unit.$re;
}
}
for($i=0; $i< count($arr3) && $i<$len2; $i++){
$bit =$arr[1][$i]; #µ±Ç°Î»Ð¡Ð´½ð¶î
$cn =$arr1[$bit]; #µ±Ç°Î»´óд½ð¶î
$unit =$arr3[$i]; #µ±Ç°Î»½ð¶îµ¥Î»
if($bit!=0) $re .=$cn.$unit;
elseif($i<2) $re .="Áã";
}
if($Format){#¸ñʽ»¯Ð¡Ð´½ð¶î
#¾«È·Î»Êý¡£²»Ð¡ÓÚ2£¬²»´óÓÚ×î´ó¾«È·¶ÈµÄСÊýλÊý
$gage =min(max(2,$len2),$pre2);
$GLOBALS[$Format]=number_format($RMB,$gage, ".", ",");
}
$re=preg_replace(
array("/ÒÚÍò/", "/(Áã)$/", "/(Áã){2,}/"),
array("ÒÚ", "",
Ïà¹ØÎĵµ£º
·½·¨1£ºerror_reporting (E_ALL ^ E_WARNING);
session_start();
·½·¨2£ºerror_reporting (E_ALL & ~E_NOTICE);
if (!isset($_SESSION)) {
session_start();
};
·½·¨3£º¸Äphp.ini ÖÐerror_reporting ......
PHP»º´æ¼¼ÊõÏê½â
Ò»¡¢»º´æ¼¼Êõ:
ÓÐЩÐÅÏ¢±È·½¾³£²»±äµÄ,µ«ÊÇ»¹ÊÇÄܱäµÄÐÅÏ¢·ÅÔÚ»º´æÖÐÒÔ¼Ó¿ìÏÔʾËÙ¶È,ÕâÊǺÜÓмÛÖµµÄ,ËùνµÄ»º´æ,ͨË×µÄÀí½â¾ÍÊÇһЩ±£´æÔÚ·þÎñÆ÷¶ËµÄ¹²ÓÃЊϢ.ËüÊÇÓÚ·þÎñÆ÷ͬÉúËÀµÄ,ÎÒÃÇÔÚ±£´æ»º´æµÄʱºò¿ÉÒÔÖ¸¶¨Ï´θüеÄʱ¼äµÄÅжÏ,±È·½ÒªÔÚ5·ÖÖÓ¸üÐÂÒ»´Î,¿ÉÒԼǼÉϴθüеÄʱ¼ ......
ǰ¶Îʱ¼äÈ¥Ò»¼Ò¹«Ë¾ÃæÊÔ£¬ÓÐÒ»µÀÌâÄ¿¾ÍÊÇ£ºÔõô°Ñ¸ø¶¨µÄÒ»¸ö×Ö·û´®ÄæÐò£¬×Ö·û´®ÖаüÀ¨ÖÐÎÄ
ÓÉÓÚµ±Ê±Ã»ÓлشðÉÏÀ´£¬ºóÀ´»Øµ½ÏÈѧУÈÏÕæÏëÁËÏ£¬Ò²ÔÚÍøÉÏÕÒÁËһЩ×ÊÁÏ£¬°´ËûÃǵķ½·¨È¥ÊµÏÖ£¬¿É½á¹û¶¼ÓÐÂÒÂ룡߯ÓôÃÆ£¬ÓÖ¹ýÁË»á¶ùÏë³öÀ´ÁËÕâ¸ö·½·¨ÈçÏ£º
------------------------------------------------------------------ ......
¡¡¡¡¹¹Ô캯ÊýÊÇPHPÖÐ×ÜÒªµÄ»ù±¾Óï·¨£¬Ê²Ã´Êǹ¹Ô캯ÊýÄØ?ÎÒÃÇÕâÀï¾ÍÒ»ÆðÀ´¿´¿´PHP¹¹Ô캯Êý¡£Èç¹ûÄãÔÚÒ»¸öÀàÖÐÉùÃ÷Ò»¸öº¯Êý,ÃüÃûΪ__construct,Õâ¸öº¯Êý½«±»µ±³ÉÊÇÒ»¸ö¹¹Ô캯Êý²¢ÔÚ½¨Á¢Ò»¸ö¶ÔÏóʵÀýʱ±»Ö´ÐÐ.Çå³þµØËµ,__ÊÇÁ½¸öÏ»®Ïß.¾ÍÏñÆäËüÈκκ¯ÊýÒ»Ñù,¹¹Ô캯Êý¿ÉÄÜÓвÎÊý»òÕßĬÈÏÖµ.Äã¿ÉÒÔ¶¨ÒåÒ»¸öÀàÀ´½¨Á¢Ò»¸ö¶ÔÏó²¢½ ......