PHPKonf Istanbul PHP Conference 2019 - Call for Papers

Класс BadFunctionCallException

(PHP 5 >= 5.1.0, PHP 7)


Создается исключение, если callback-функция относится к неопределенной функции или если некоторые аргументы отсутствуют.

Обзор классов

BadFunctionCallException extends LogicException {
/* Наследуемые свойства */
protected string $message ;
protected int $code ;
protected string $file ;
protected int $line ;
/* Наследуемые методы */
final public string Exception::getMessage ( void )
final public Throwable Exception::getPrevious ( void )
final public mixed Exception::getCode ( void )
final public string Exception::getFile ( void )
final public int Exception::getLine ( void )
final public array Exception::getTrace ( void )
final public string Exception::getTraceAsString ( void )
public string Exception::__toString ( void )
final private void Exception::__clone ( void )
add a note add a note

User Contributed Notes 4 notes

tom at tomwardrop dot com
9 years ago
A typical use for this exception, is in conjunction with the is_callable() function.
evguenia dot chagnon at gmail dot com
1 year ago
For example:

function foo($arg) {
    $func = 'do' . $arg;
    if (!is_callable($func)) {
        throw new BadFunctionCallException('Function ' . $func . ' is not callable');
roland at mxchange dot org
1 year ago
You can also throw BadMethodCallException within a method when certain pre-conditions to safely call that method are not met.

For example when a method <?php $foo->analyzeData(); ?> has been called but no data as previously been loaded (from file "import" for database, wherever from).
Dawid Krysiak
7 years ago
Direct known subclasses:

So BadMethodCallException can be used in case the subject function is or should be a part of class / object - it's use defines the case more precisely.
To Top