Home >Backend Development >PHP Tutorial >php function_exists function problem, repeatedly defining functions

php function_exists function problem, repeatedly defining functions

WBOY
WBOYOriginal
2016-08-04 09:21:291739browse

<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

Reply content:

<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..

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn