mirror of
https://github.com/sigmasternchen/php-doc-en
synced 2025-03-16 00:48:54 +00:00
Better example for #52499
git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@302257 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
parent
966294f125
commit
de537ccab1
1 changed files with 15 additions and 7 deletions
|
@ -188,25 +188,33 @@ object(SimpleClass)#1 (1) {
|
|||
<?php
|
||||
class Test
|
||||
{
|
||||
public function getNew()
|
||||
static public function getNew()
|
||||
{
|
||||
return new static;
|
||||
}
|
||||
}
|
||||
|
||||
$obj1 = new Test();
|
||||
$obj2 = $obj1->getNew();
|
||||
$obj3 = new $obj2;
|
||||
class Child extends Test
|
||||
{}
|
||||
|
||||
var_dump($obj1 === $obj2, $obj2 === $obj3);
|
||||
$obj1 = new Test();
|
||||
$obj2 = new $obj1;
|
||||
var_dump($obj1 !== $obj2);
|
||||
|
||||
$obj3 = Test::getNew();
|
||||
var_dump($obj3 instanceof Test);
|
||||
|
||||
$obj4 = Child::getNew();
|
||||
var_dump($obj4 instanceof Child);
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
&example.outputs;
|
||||
<screen>
|
||||
<![CDATA[
|
||||
bool(false)
|
||||
bool(false)
|
||||
bool(true)
|
||||
bool(true)
|
||||
bool(true)
|
||||
]]>
|
||||
</screen>
|
||||
</example>
|
||||
|
|
Loading…
Reference in a new issue