L
L
lumpenkoder2020-05-09 23:53:10
PHP
lumpenkoder, 2020-05-09 23:53:10

Why is Null returned?

the code itself:

public function add($name, $method)
    {
        $func = $this->{$name};
        if(!isset($func))
        {
            $this->{$name} = $method;
        }
        return true;
    }

calling
$context->add("getUser", function () use ($vk) {
        return $vk->api->request("users.get", [])[0]["first_name"];
    });


server returns
Fatal error: Call to a member function add() on null in

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Rsa97, 2020-05-09
@lumpencoder

The error message says that you are trying to call the add method on null, which means that your $context variable contains null. It is not possible to name the reason for this code.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question