mirror of
https://github.com/sigmasternchen/php-doc-en
synced 2025-03-16 00:48:54 +00:00
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:
parent
f4fbc4ea73
commit
966294f125
1 changed files with 33 additions and 0 deletions
|
@ -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>
|
||||
|
|
Loading…
Reference in a new issue