首頁  >  文章  >  後端開發  >  php function_exists函數問題,重複定義函數

php function_exists函數問題,重複定義函數

WBOY
WBOY原創
2016-08-04 09:21:291683瀏覽

<code>$a=get(1);  //出错,找不到定义
echo $a;
if(!function_exists("get")){
   function get($a){
      return "test";
   }
}</code>

想實現功能,就是檢測這函數有沒有定義,有的話,就不定義了,沒有就定義下
function_exists位置在文件尾部,提示找不到函數定義

回覆內容:

<code>$a=get(1);  //出错,找不到定义
echo $a;
if(!function_exists("get")){
   function get($a){
      return "test";
   }
}</code>

想實現功能,就是檢測這函數有沒有定義,有的話,就不定義了,沒有就定義下
function_exists位置在文件尾部,提示找不到函數定義

<code class="php">if(!function_exists("get")){
   function get($a){
      return "test";
   }
}
$a=get(1); // 这不就找到了
echo $a;</code>

推薦用方法is_callable,手冊

解釋順序執行..

陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn