判断函数是否存在
當我們創建了自定義函數,并且了解了可變函數的用法,為了確保程序調用的函數是存在的,經常會先使用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.'; }
?
轉載于:https://www.cnblogs.com/shark1100913/p/5568347.html
總結
- 上一篇: CXF之webservice
- 下一篇: 【剑仙教程】易语言的结构体。自定义数据类