2024 PHP Conference Japan

BadFunctionCallException 類別

(PHP 5 >= 5.1.0, PHP 7, PHP 8)

簡介

如果回呼函式參考了未定義的函式或缺少某些參數,則會拋出此例外。

類別概要

class BadFunctionCallException extends LogicException {
/* 繼承的屬性 */
protected 字串 $message = "";
private 字串 $string = "";
保護的 整數 $code;
保護的 字串 $file = "";
保護的 整數 $line;
私有的 陣列 $trace = [];
私有的 ?可拋出物件 $previous = null;
/* 繼承的方法 */
公開的 Exception::__construct(字串 $message = "", 整數 $code = 0, ?可拋出物件 $previous = null)
最終 公開的 Exception::getMessage(): 字串
最終 公開的 Exception::getCode(): 整數
最終 公開的 Exception::getFile(): 字串
最終 公開的 Exception::getLine(): 整數
最終 公開的 Exception::getTrace(): 陣列
私有的 Exception::__clone():
}
新增筆記

使用者貢獻的筆記 2 則筆記

evguenia dot chagnon at gmail dot com
7 年前
例如:

function foo($arg) {
$func = 'do' . $arg;
if (!is_callable($func)) {
throw new BadFunctionCallException('函式 ' . $func . ' 不可呼叫');
}
}
tom at tomwardrop dot com
15 年前
此例外的一般用法是與 is_callable() 函式一起使用。
To Top