首頁 >後端開發 >php教程 >php闈欐€佸彉閲廳efine,static,const_PHP鏁欑▼ | 甯涔嬪

php闈欐€佸彉閲廳efine,static,const_PHP鏁欑▼ | 甯涔嬪

WBOY
WBOY原創
2016-07-20 11:02:181312瀏覽

 

闈欐€佸彉閲忓彧瀛樺湪浜庡嚱鏁颁綔鐢ㄥ煙鍐咃紝涔熷氨鏄锛岄潤鎬佸彉閲忓彧瀛樻椿鍦ㄦ爤涓€備竴鑸殑鍑芥暟鍐呭彉閲忓湪鍑芥暟缁撴潫鍚庝細閲婃斁锛屾瘮濡傚眬閮ㄥ彉閲忥紝浣嗘槸闈欐€佸彉閲忓嵈涓嶄細銆傚氨鏄锛屼笅娆″啀璋冪敤杩欎釜鍑芥暟鐨勬椂鍊欙紝璇ュ彉閲忕殑鍊间細淇濈暀涓嬫潵

鏈€绠€鍗曞畾涔夋柟娉?/p>

define() 鍑芥暟瀹氫箟涓€涓父閲忋€?/p>

甯搁噺绫讳技鍙橀噺锛屼笉鍚屼箣澶勫湪浜庯細

鍦ㄨ瀹氫互鍚庯紝甯搁噺鐨勫€兼棤娉曟洿鏀?br /> 甯搁噺鍚嶄笉闇€瑕佸紑澶寸殑缇庡厓绗﹀彿 ($)
浣滅敤鍩熶笉褰卞搷瀵瑰父閲忕殑璁块棶
甯搁噺鍊煎彧鑳芥槸瀛楃涓叉垨鏁板瓧
璇硶

define(name,value,case_insensitive)

class foo {
   static $my_static = 5;
   public $my_prop = 'bla';
}

print foo::$my_static; copyright dedecms
$obj = new foo;
print $obj->my_prop;
?>

const 鏄父閲忥紝鍗充粠绋嬪簭杩愮畻寮€濮嬪埌缁撴潫锛屾暟鍊间笉鍙樼殑閲忋€?/p>

class say_const{  
const charset=”涓浗”锛?nbsp; 
publice function say_hello(){  
echo slef::charset;  
}  
}  
$const1=new say_const()’  
$const1->say_hello();  
?>  

杈撳嚭灏辨槸“涓浗”

涓嬮潰涓€娆惧畬鏁寸殑闈欐€佸彉閲?/p>

function write_file($file,$msg,$usecheck=5){
 static $check=1;//杩欓噷鐢ㄥ埌浜唦
 $f=@fopen($file,"a+b");
 if($f){
  if(flock($f,lock_ex)){
   fwrite($f,$msg);
   flock($f,lock_un);
   fclose($f);
  }else{
   fclose($f);
   $check++;
   if($check     sleep(1);//鏆傚仠涓嬬▼搴?绛夊叾浠栬繘绋嬮噴鏀捐璧勬簮
    write_file($file,$msg);
   }
  }
 }else{
  $check++;
  if($check    sleep(1);//鏆傚仠涓嬬▼搴?绛夊叾浠栬繘绋嬮噴鏀捐璧勬簮
   write_file($file,$msg);
  }
 }
}


www.bkjia.comtruehttp://www.bkjia.com/PHPjc/445372.htmlTechArticle闈欐€佸彉閲忓彧瀛樺湪浜庡嚱鏁颁綔鐢ㄥ煙鍐咃紝涔熷氨鏄锛岄潤鎬佸彉閲忓彧瀛樻椿鍦ㄦ爤涓€備竴鑸殑鍑芥暟鍐呭彉閲忓湪鍑芥暟缁撴潫鍚庝細閲婃斁锛屾瘮濡傚眬閮ㄥ彉閲忥紝浣嗘槸闈欐€佸彉...
陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn