mirror of
https://github.com/sigmasternchen/php-doc-en
synced 2025-03-16 00:48:54 +00:00
fix #37702: __toString() is now more magical since php 5.2
git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@218035 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
parent
9b6b17646b
commit
ca562b60e8
1 changed files with 3 additions and 26 deletions
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision: 1.12 $ -->
|
||||
<!-- $Revision: 1.13 $ -->
|
||||
<sect1 id="language.oop5.magic">
|
||||
<title>Magic Methods</title>
|
||||
<para>
|
||||
|
@ -139,33 +139,10 @@ Hello
|
|||
</screen>
|
||||
</example>
|
||||
<para>
|
||||
It is worth noting that the <literal>__toString</literal> method
|
||||
will only be called when it is directly combined with
|
||||
It is worth noting that before PHP 5.2.0 the <literal>__toString</literal>
|
||||
method was only called when it was directly combined with
|
||||
<function>echo</function> or <function>print</function>.
|
||||
</para>
|
||||
<example>
|
||||
<title>Cases where <literal>__toString</literal> is called</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
// __toString called
|
||||
echo $class;
|
||||
|
||||
// __toString called (still a normal parameter for echo)
|
||||
echo 'text', $class;
|
||||
|
||||
// __toString not called (concatenation operator used first)
|
||||
echo 'text' . $class;
|
||||
|
||||
// __toString not called (cast to string first)
|
||||
echo (string) $class;
|
||||
|
||||
// __toString not called (cast to string first)
|
||||
echo "text $class";
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
</sect2>
|
||||
|
||||
<sect2 id="language.oop5.magic.set-state">
|
||||
|
|
Loading…
Reference in a new issue