Re: [PHP-DEV] Fatal error: Call to a member function on a non-object

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux