首页 > 其他 > 详细

判断函数是否存在

时间:2016-06-07 22:19:24      阅读:175      评论:0      收藏:0      [点我收藏+]

当我们创建了自定义函数,并且了解了可变函数的用法,为了确保程序调用的函数是存在的,经常会先使用function_exists判断一下函数是否存在。同样的method_exists可以用来检测类的方法是否存在。

判断函数是否存在  function_exists()
function
func() {
}
if(function_exists(‘func‘))
{
    echo"存在";
}
判断类是否存在 class_exists()
class
func {
} 
 // 使用前检查类是否存在
if(class_exists(‘func‘)) { $func = new func(); }
判断文件是否存在

$filename
= ‘test.txt‘; if (!file_exists($filename)) { echo $filename . ‘ not exists.‘; }

 

判断函数是否存在

原文:http://www.cnblogs.com/shark1100913/p/5568347.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!