Fixed PHP bug #52499 (new keyword not fully documented)

git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@302256 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
Daniel Egeberg 2010-08-15 07:29:10 +00:00
parent f4fbc4ea73
commit 966294f125

View file

@ -174,6 +174,39 @@ object(SimpleClass)#1 (1) {
["var"]=>
string(30) "$assigned will have this value"
}
]]>
</screen>
</example>
<para>
PHP 5.3.0 introduced a couple of new ways to create instances of an
object:
</para>
<example>
<title>Creating new objects</title>
<programlisting role="php">
<![CDATA[
<?php
class Test
{
public function getNew()
{
return new static;
}
}
$obj1 = new Test();
$obj2 = $obj1->getNew();
$obj3 = new $obj2;
var_dump($obj1 === $obj2, $obj2 === $obj3);
?>
]]>
</programlisting>
&example.outputs;
<screen>
<![CDATA[
bool(false)
bool(false)
]]>
</screen>
</example>