Home >Backend Development >PHP Tutorial >动态调用函数_PHP

动态调用函数_PHP

WBOY
WBOYOriginal
2016-06-01 12:30:26834browse




动态调用函数




 function write($text)  //定义function write()函数
 {
  print($text);  //打印字符串
 }

 function writeBold($text) //定义function write()函数
 {
  print("$text"); //打印字符串
 }

 $myFunction = "write";  //定义变量
 $myFunction("你好!
"); //由于变量后面有括号,所以找名字相同的function函数
 print("
\n");
 $myFunction = "writeBold"; //定义变量
 $myFunction("再见!");  //由于变量后面有括号,所以找名字相同的function函数
 print("
\n");
?>



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