tirenweb
tirenweb

Reputation: 31709

PHP: Non static method called as it was static, how is that possible?

is there anyway to call a non static method, as an static method?

I have found this call:

$handler =& ProfileHandler_Array::getInstance(
    array(  'username'        => $this->api_username,
            'certificateFile' => $this->api_certificate,
            'signature'       => $this->api_signature,
            'subject'         => $this->api_subject,
            'environment'     => (($this->api_test)?'Sandbox':'Live')
    )

And here you have getInstance() method:

function getInstance($id, &$handler)
{
    $classname = __CLASS__;
    $inst = new $classname($id, $handler);

    $result = $inst->_load();
    if (PayPal::isError($result)) {
        return $result;
    }

    $result = $inst->loadEnvironments();
    if (PayPal::isError($result)) {
        return $result;
    }

    return $inst;
}

and it doesn't give any errors!!!!

More clues: it's maybe an old code.

Regards

Upvotes: 1

Views: 236

Answers (1)

NikiC
NikiC

Reputation: 101906

Your code should give an error, it just isn't displayed. (Is error_reporting set to E_ALL | E_STRICT? Is display_errors enabled?)

From the manual:

Calling non-static methods statically generates an E_STRICT level warning.

Upvotes: 2

Related Questions