Re: Fatal error: Call to a member function on a non-object
| From: | Paweł Stradomski | Date: | Mon, 17 Nov 2008 10:34:13 +0000 |
| Subject: | Re: Fatal error: Call to a member function on a non-object | ||
| References: | 1 2 3 | Groups: | php.general php.internals |
| Request: | Send a blank email to internals+get-41964@lists.php.net to get a copy of this message | ||
W liście Christopher Vogt z dnia poniedziałek 17 listopada 2008:
> I have a good understanding of OOP. This is not a start for me. I am
> just refactoring existing PHP code to be object-oriented. You say there
> are plenty of reasons for a Fatal error, so please tell me a few, so I
> understand the reasons.
You're calling a method. This requires code execution, but the code isn't
there. If you were accessing a property of non-existing object (that is, if
you were doing $user->fullname;) then you'd get a warning and NULL. It's not
so for functions, as they're request for code execution, not for value
(remember, not all functions return values as they most important effect -
it's not Haskell).
Calling non-existing function returns in fatal error in PHP; it's the same
for:
$object->iHaveNoSuchMethod();
$null->method();
nosuchfunction();
--
Paweł Stradomski