Hi 2008/11/17 Christopher Vogt <[EMAIL PROTECTED]>: > Hej, > > I use PHP 5.2.6. I am refactoring some code to use more > object-orientation. I encounter a problem, where the new object-oriented > version results in a fatal error, where the old array-oriented version > didn't. > > I fetch records a database. Sometime it happens that a record does not > exist anymore. Let's assume it's a user, then $user will be NULL. > > echo $user['fullname']; // no error at all, $user['fullname'] === NULL > > Shouldn't this at least trigger a Notice? > > echo $user->get_fullname(); // Fatal error > > I agree this should trigger an error, but a "Fatal error" is a little > too much, I think. It terminates the script leaving the html-document > incomplete. I would prefer a "Warning" and NULL instead. > > Is there any reason against it?
I personally don't really mind it, as you got the instanceof and typehinting to check for whenever a variable is an object, so I would say its more of a user design issue. Fatal errors just requires you to refactor your code so your code shouldn't emit such things which I'm alright with. > > Best regards > > Christopher > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > > -- Kalle Sommer Nielsen -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php