Maison > Article > développement back-end > php榄旀湳鏂规硶鍜岄瓟鏈彉閲
php榄旀湳鏂规硶鍜岄瓟鏈彉閲?
PHP鎶婃墍鏈変互__锛堜袱涓笅鍒掔嚎锛夊紑澶寸殑绫绘柟娉曞綋鎴愰瓟鏈柟娉曘?傛墍浠ヤ綘瀹氫箟鑷繁鐨勭被鏂规硶鏃讹紝涓嶈浠?/span> __涓哄墠缂?銆?/span>
聽
1銆?/span>__construct()
褰撳疄渚嬪寲涓?涓璞$殑鏃跺?欙紝杩欎釜瀵硅薄鐨勬瀯閫犳柟娉曞皢棣栧厛琚皟鐢紱
鎴戜滑鐭ラ亾php5瀵硅薄妯″瀷鍜岀被鍚嶇浉鍚岀殑鍑芥暟鏄被鐨勬瀯閫犲嚱鏁帮紝閭d箞濡傛灉鍚屾椂瀹氫箟鏋勯?犲嚱鏁板拰__construc()鏂规硶鐨勮瘽锛?/span>php5浼氶粯璁よ皟鐢?/span>__contruct()鑰屼笉浼氳皟鐢ㄥ悓绫诲悕鍑芥暟锛屾墍浠?/span>__contruct()浣滀负绫荤殑榛樿鏋勯?犲嚱鏁帮紱
聽
2銆?/span>__destruct()
鏋愭瀯鍑芥暟浼氬湪鍒版煇涓璞$殑鎵?鏈夊紩鐢ㄩ兘琚垹闄ゆ垨鑰呭綋瀵硅薄琚樉寮忛攢姣佹椂鎵ц銆?/span>
聽
3銆?/span>__get(string $name)
褰撹瘯鍥捐鍙栦竴涓苟涓嶅瓨鍦ㄧ殑灞炴?ф椂琚皟鐢紱濡傛灉璇曞浘璇诲彇涓?涓璞″苟涓嶅瓨鍦ㄧ殑灞炴?х殑鏃跺?欙紝php灏变細缁欏嚭閿欒鐨勪俊鎭?傚鏋滃湪绫婚噷娣诲姞__get鏂规硶锛屽苟涓旀垜浠彲浠ョ敤杩欎釜鍑芥暟瀹炵幇绫讳技java涓殑鍙嶅皠鐨勫悇绉嶆搷浣溿??/span>
聽
4銆?/span>__set(string $name, mixed $value)
缁欐湭瀹氫箟鐨勫彉閲忚祴鍊兼椂灏嗚璋冪敤
聽
5銆?/span>__call(string $name, array $arguments)
褰撹皟鐢ㄤ竴涓笉鍙闂柟娉曪紙濡傛湭瀹氫箟锛屾垨鑰呬笉鍙锛夋椂锛宊_call() 浼氳璋冪敤銆?/span>
__callStatic(string $name, array $arguments)
褰撳湪闈欐?佹柟娉曚腑璋冪敤涓?涓笉鍙闂柟娉曪紙濡傛湭瀹氫箟锛屾垨鑰呬笉鍙锛夋椂锛宊_callStatic() 浼氳璋冪敤銆?/span>
聽
6銆?/span>__toString()
褰撴墦鍗颁竴涓璞$殑鏃跺?欒璋冪敤锛岃繖涓柟娉曠被浼间簬java鐨?/span>toString鏂规硶锛屽綋鎴戜滑鐩存帴鎵撳嵃瀵硅薄鐨勬椂鍊欏洖璋冭繖涓嚱鏁般??/span>
聽
7銆?/span>__clone()
褰撳璞¤鍏嬮殕鏃惰皟鐢ㄣ??/span>
聽
8銆?/span>__sleep()
serialize()鍑芥暟浼氭鏌ユ槸鍚﹀瓨鍦ㄤ竴涓瓟鏈柟娉?/span> __sleep.濡傛灉瀛樺湪锛?/span>__sleep()鏂规硶浼氬厛琚皟鐢紝 鐒跺悗鎵嶆墽琛屽簭鍒楀寲鎿嶄綔銆傝繖涓姛鑳藉彲浠ョ敤浜庢竻鐞嗗璞★紝骞惰繑鍥炰竴涓寘鍚璞′腑鎵?鏈夊彉閲忓悕绉扮殑鏁扮粍銆傚鏋滆鏂规硶涓嶈繑鍥炰换浣曞唴瀹癸紝鍒?/span>NULL琚簭鍒楀寲锛屽鑷?/span> 涓?涓?/span>E_NOTICE閿欒銆俖_sleep鏂规硶甯哥敤浜庢彁浜ゆ湭鎻愪氦鐨勬暟鎹紝鎴栫被浼肩殑鎿嶄綔銆傚悓鏃讹紝濡傛灉浣犳湁涓?浜涘緢澶х殑瀵硅薄锛屼笉闇?瑕佷繚瀛橈紝杩欎釜鍔熻兘灏卞緢濂界敤銆?/span>
聽
9銆?/span>__wakeup()
涓?/span>__sleep() 鐩稿弽锛?/span>unserialize()浼氭鏌ユ槸鍚﹀瓨鍦ㄤ竴涓猒_wakeup鏂规硶銆傚鏋滃瓨鍦紝鍒欎細鍏堣皟鐢?/span> __wakeup鏂规硶锛岄鍏堝噯澶囧璞℃暟鎹??/span> __wakeup缁忓父鐢ㄥ湪鍙嶅簭鍒楀寲鎿嶄綔涓紝渚嬪閲嶆柊寤虹珛鏁版嵁搴撹繛鎺ワ紝鎴栨墽琛屽叾瀹冨垵濮嬪寲鎿嶄綔銆?/span>
10銆?/span>__isset()
褰撳鏈畾涔夌殑鍙橀噺璋冪敤isset() 鎴?/span> empty()鏃讹紝__isset() 浼氳璋冪敤銆?/span>
聽
11銆?/span>__unset()
unset涓?涓璞$殑灞炴?ф椂琚皟鐢ㄣ?傚锛?/span>unset($c->name)銆?/span>
聽
12銆?/span>__set_state()
璋冪敤var_export鏃讹紝琚皟鐢ㄣ?傜敤__set_state鐨勮繑鍥炲?煎仛涓?/span>var_export鐨勮繑鍥炲?笺??/span>
聽
13銆?/span>__autoload()
瀹炰緥鍖栦竴涓璞℃椂锛屽鏋滃搴旂殑绫讳笉瀛樺湪锛屽垯璇ユ柟娉曡璋冪敤銆傜畝鍗曠殑璇村氨鏄被鐨勮嚜鍔ㄥ姞杞?/span>;褰撲綘灏濊瘯浣跨敤涓?涓?/span>PHP娌℃湁缁勭粐鍒扮殑绫?/span>, 瀹冧細瀵绘壘涓?涓?/span>__autoload鐨勫叏灞?鍑芥暟. 濡傛灉瀛樺湪杩欎釜鍑芥暟,PHP浼氱敤涓?涓弬鏁版潵璋冪敤瀹?/span>,鍙傛暟鍗崇被鐨勫悕绉般??/span>
聽
14銆?/span>__invoke()
褰撳皾璇曚互璋冪敤鍑芥暟鐨勬柟寮忚皟鐢ㄤ竴涓璞℃椂锛宊_invoke 鏂规硶浼氳鑷姩璋冪敤銆?/span>
聽
榄旀湳甯搁噺:
__LINE__ 鏂囦欢涓殑褰撳墠琛屽彿銆?/span>聽
__FILE__ 鏂囦欢鐨勫畬鏁磋矾寰勫拰鏂囦欢鍚嶃?傚鏋滅敤鍦ㄨ鍖呭惈鏂囦欢涓紝鍒欒繑鍥炶鍖呭惈鐨勬枃浠跺悕銆傝嚜 PHP 4.0.2 璧凤紝__FILE__ 鎬绘槸鍖呭惈涓?涓粷瀵硅矾寰勶紙濡傛灉鏄鍙疯繛鎺ワ紝鍒欐槸瑙f瀽鍚庣殑缁濆璺緞锛夛紝鑰屽湪姝や箣鍓嶇殑鐗堟湰鏈夋椂浼氬寘鍚竴涓浉瀵硅矾寰勩??/span>聽
__DIR__ 鏂囦欢鎵?鍦ㄧ殑鐩綍銆傚鏋滅敤鍦ㄨ鍖呮嫭鏂囦欢涓紝鍒欒繑鍥炶鍖呮嫭鐨勬枃浠舵墍鍦ㄧ殑鐩綍銆傚畠绛変环浜?/span> dirname(__FILE__)銆傞櫎闈炴槸鏍圭洰褰曪紝鍚﹀垯鐩綍涓悕涓嶅寘鎷湯灏剧殑鏂滄潬銆傦紙PHP 5.3.0涓柊澧烇級 =聽
__FUNCTION__ 鍑芥暟鍚嶇О锛?/span>PHP 4.3.0 鏂板姞锛夈?傝嚜 PHP 5 璧锋湰甯搁噺杩斿洖璇ュ嚱鏁拌瀹氫箟鏃剁殑鍚嶅瓧锛堝尯鍒嗗ぇ灏忓啓锛夈?傚湪 PHP 4 涓鍊兼?绘槸灏忓啓瀛楁瘝鐨勩??/span>聽
__CLASS__ 绫荤殑鍚嶇О锛?/span>PHP 4.3.0 鏂板姞锛夈?傝嚜 PHP 5 璧锋湰甯搁噺杩斿洖璇ョ被琚畾涔夋椂鐨勫悕瀛楋紙鍖哄垎澶у皬鍐欙級銆傚湪 PHP 4 涓鍊兼?绘槸灏忓啓瀛楁瘝鐨勩??/span>聽
__METHOD__ 绫荤殑鏂规硶鍚嶏紙PHP 5.0.0 鏂板姞锛夈?傝繑鍥炶鏂规硶琚畾涔夋椂鐨勫悕瀛楋紙鍖哄垎澶у皬鍐欙級銆?/span>聽
__NAMESPACE__ 褰撳墠鍛藉悕绌洪棿鐨勫悕绉帮紙澶у皬鍐欐晱鎰燂級銆傝繖涓父閲忔槸鍦ㄧ紪璇戞椂瀹氫箟鐨勶紙PHP 5.3.0 鏂板锛?/span>聽