Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:41956 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 50071 invoked from network); 17 Nov 2008 08:01:13 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 17 Nov 2008 08:01:13 -0000 X-Host-Fingerprint: 134.130.78.10 unknown Received: from [134.130.78.10] ([134.130.78.10:1273] helo=localhost.localdomain) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 28/8E-39815-8C421294 for ; Mon, 17 Nov 2008 03:01:13 -0500 Message-ID: <28.8E.39815.8C421294@pb1.pair.com> To: internals@lists.php.net Date: Mon, 17 Nov 2008 09:01:09 +0100 User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.0.7) Gecko/20060909 Thunderbird/1.5.0.7 Mnenhy/0.7.4.666 MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: 7bit X-Posted-By: 134.130.78.10 Subject: Fatal error: Call to a member function on a non-object From: christopher.vogt@rwth-aachen.de (Christopher Vogt) 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? Best regards Christopher