PHP閿欒鎺у埗杩愮畻绗

鍐呭鎽樿
PHP 鏀寔涓涓敊璇帶鍒惰繍绠楃锛欯銆傚綋灏嗗叾鏀剧疆鍦ㄤ竴涓 PHP 琛ㄨ揪寮忎箣鍓嶏紝璇ヨ〃杈惧紡鍙兘浜х敓鐨勪换浣曢敊璇俊鎭兘琚拷鐣ユ帀銆
鏂囩珷姝f枃
閿欒鎺у埗杩愮畻绗
PHP 鏀寔涓涓敊璇帶鍒惰繍绠楃锛欯銆傚綋灏嗗叾鏀剧疆鍦ㄤ竴涓 PHP 琛ㄨ揪寮忎箣鍓嶏紝璇ヨ〃杈惧紡鍙兘浜х敓鐨勪换浣曢敊璇俊鎭兘琚拷鐣ユ帀銆

濡傛灉婵娲讳簡 鐗规э紝琛ㄨ揪寮忔墍浜х敓鐨勪换浣曢敊璇俊鎭兘琚瓨鏀惧湪鍙橀噺 $php_errormsg 涓傛鍙橀噺鍦ㄦ瘡娆″嚭閿欐椂閮戒細琚鐩栵紝鎵浠ュ鏋滄兂鐢ㄥ畠鐨勮瘽灏辫灏芥棭妫鏌ャ

<?php
/* Intentional file error */
$my_file = @file ('non_existent_file') or
    die ("Failed opening file: error was '$php_errormsg'");

// this works for any expression, not just functions:
$value = @$cache[$key];
// will not issue a notice if the index $key doesn't exist.

?>

Note: @ 杩愮畻绗﹀彧瀵硅〃杈惧紡鏈夋晥銆傚鏂版墜鏉ヨ涓涓畝鍗曠殑瑙勫垯灏辨槸锛氬鏋滆兘浠庢煇澶勫緱鍒板硷紝灏辫兘鍦ㄥ畠鍓嶉潰鍔犱笂 @ 杩愮畻绗︺備緥濡傦紝鍙互鎶婂畠鏀惧湪鍙橀噺锛屽嚱鏁板拰 include() 璋冪敤锛屽父閲忥紝绛夌瓑涔嬪墠銆備笉鑳芥妸瀹冩斁鍦ㄥ嚱鏁版垨绫荤殑瀹氫箟涔嬪墠锛屼篃涓嶈兘鐢ㄤ簬鏉′欢缁撴瀯渚嬪 if 鍜 foreach 绛夈

鍙傝 error_reporting() 鍙婃墜鍐屼腑閿欒澶勭悊鍙婃棩蹇楀嚱鏁扮殑鏈夊叧绔犺妭銆

Warning
鐩墠鐨勨淍鈥濋敊璇帶鍒惰繍绠楃鍓嶇紑鐢氳嚦浣垮鑷磋剼鏈粓姝㈢殑涓ラ噸閿欒鐨勯敊璇姤鍛婁篃澶辨晥銆傝繖鎰忓懗鐫濡傛灉鍦ㄦ煇涓笉瀛樺湪鎴栫被鍨嬮敊璇殑鍑芥暟璋冪敤鍓嶇敤浜嗏淍鈥濇潵鎶戝埗閿欒淇℃伅锛岄偅鑴氭湰浼氭病鏈変换浣曡抗璞℃樉绀哄師鍥犺屾鍦ㄩ偅閲屻

浠ヤ笂灏辨槸PHP閿欒鎺у埗杩愮畻绗︾殑璇︾粏鍐呭锛屾洿澶氫俊鎭鍏虫敞OD浜戝叾瀹冪浉鍏虫枃绔狅紒



鏈枃URL锛http://www.odweb.cn/news_show.html?id=66