From 03977edc1f92ef56b1141f05388cf400e3f09fcd Mon Sep 17 00:00:00 2001 From: Philip Olson Date: Thu, 16 Sep 2010 23:48:26 +0000 Subject: [PATCH] Clarify __tostring() a little, and mention it must return a string. git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@303436 c90b9560-bf6c-de11-be94-00142212c4b1 --- language/oop5/magic.xml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/language/oop5/magic.xml b/language/oop5/magic.xml index 2d601de420..82c528a0ee 100644 --- a/language/oop5/magic.xml +++ b/language/oop5/magic.xml @@ -114,7 +114,10 @@ class Connection <literal>__toString</literal> The __toString method allows a class to decide - how it will react when it is converted to a string. + how it will react when it is treated like a string. For example, + what echo $obj; will print. This method must + return a string, as otherwise a fatal E_RECOVERABLE_ERROR + level error is emitted. Simple example