Home >Backend Development >PHP Tutorial >php function_exists function problem, repeatedly defining functions
<code>$a=get(1); //出错,找不到定义 echo $a; if(!function_exists("get")){ function get($a){ return "test"; } }</code>
If you want to realize the function, you need to check whether the function is defined. If it is, it will not be defined. If not, just define it.
The function_exists position is at the end of the file, and it will prompt that the function definition cannot be found
<code>$a=get(1); //出错,找不到定义 echo $a; if(!function_exists("get")){ function get($a){ return "test"; } }</code>
If you want to realize the function, you need to check whether the function is defined. If it is, it will not be defined. If not, just define it.
The function_exists position is at the end of the file, and it will prompt that the function definition cannot be found
<code class="php">if(!function_exists("get")){ function get($a){ return "test"; } } $a=get(1); // 这不就找到了 echo $a;</code>
Recommended methodis_callable
, manual
Explanation of sequential execution..