Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:54288 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 29934 invoked from network); 2 Aug 2011 14:48:04 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 2 Aug 2011 14:48:04 -0000 Authentication-Results: pb1.pair.com smtp.mail=rquadling@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=rquadling@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.216.42 as permitted sender) X-PHP-List-Original-Sender: rquadling@gmail.com X-Host-Fingerprint: 209.85.216.42 mail-qw0-f42.google.com Received: from [209.85.216.42] ([209.85.216.42:55452] helo=mail-qw0-f42.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 4C/38-19408-32E083E4 for ; Tue, 02 Aug 2011 10:48:03 -0400 Received: by qwi4 with SMTP id 4so3812419qwi.29 for ; Tue, 02 Aug 2011 07:48:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:reply-to:from:date:message-id:subject:to:content-type; bh=DvpQN37py4j4Erou9iauPe9ZkDn3RHonL+aXTUhyCWY=; b=iaJ2gS7ywoKZr+nbsbJ/FQr1SaUQyBZNm63swq0ydcT/9iXyD4cOmxgH9cG+pYPqzB VylIpU1mKtbF09ZjZgmJ7WI3k54oSXTjHefVles/SXlplJxQLxvj59hoUkzaeB6KXqFu M4Ls4F47LDoHPcBo8mp2X6x26jmpj6jGM963E= Received: by 10.229.46.18 with SMTP id h18mr1422161qcf.141.1312296480560; Tue, 02 Aug 2011 07:48:00 -0700 (PDT) MIME-Version: 1.0 Received: by 10.229.81.14 with HTTP; Tue, 2 Aug 2011 07:47:38 -0700 (PDT) Reply-To: RQuadling@GMail.com Date: Tue, 2 Aug 2011 15:47:38 +0100 Message-ID: To: PHP internals Content-Type: text/plain; charset=UTF-8 Subject: asString() method vs __toString() magic method. From: rquadling@gmail.com (Richard Quadling) Hi. Given the relatively simple code below, why can't I throw an exception in __toString()? asString(); } catch(Exception $ex) { echo $ex->getMessage(); } try { echo $failure; } catch(Exception $ex) { echo $ex->getMessage(); } ?> outputs ... Failed in asString() Fatal error: Method AlwaysFails::__toString() must not throw an exception in Z:\fa1.php on line 21 -- Richard Quadling Twitter : EE : Zend : PHPDoc @RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY : bit.ly/lFnVea