#26260 [Opn->Bgs]: Example In Changes in PHP 5/Zend Engine 2.0
| From: | iliaa@php.net | Date: | Sat, 15 Nov 2003 18:34:52 +0000 |
| Subject: | #26260 [Opn->Bgs]: Example In Changes in PHP 5/Zend Engine 2.0 | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-50414@lists.php.net to get a copy of this message | ||
ID: 26260
Updated by: iliaa@php.net
Reported By: chongwh at yahoo dot com
-Status: Open
+Status: Bogus
Bug Type: Output Control
Operating System: winxp
PHP Version: 5.0.0b2 (beta2)
New Comment:
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to
report
a bug at http://bugs.php.net/how-to-report.php
Read documentation.
Previous Comments:
------------------------------------------------------------------------
[2003-11-15 08:24:57] chongwh at yahoo dot com
Description:
------------
Below is the first php example found in "Changes in PHP 5/Zend Engine
2.0 "
<?php
class MyClass {
private $Hello = "Hello, World!\n";
protected $Bar = "Hello, Foo!\n";
protected $Foo = "Hello, Bar!\n";
function printHello() {
print "MyClass::printHello() " . $this->Hello;
print "MyClass::printHello() " . $this->Bar;
print "MyClass::printHello() " . $this->Foo;
}
}
class MyClass2 extends MyClass {
protected $Foo;
function printHello() {
MyClass::printHello(); /* Should print
*/
print "MyClass2::printHello() " . $this->Hello; /* Shouldn't
print out anything */
print "MyClass2::printHello() " . $this->Bar; /* Shouldn't
print (not declared)*/
print "MyClass2::printHello() " . $this->Foo; /* Should print
*/
}
}
$obj = new MyClass();
print $obj->Hello; /* Shouldn't print out anything */
print $obj->Bar; /* Shouldn't print out anything */
print $obj->Foo; /* Shouldn't print out anything */
$obj->printHello(); /* Should print */
?>
The result not same as stated in the remark. No print for
$obj->printHello().
It only print with the code below
$obj = new MyClass();
//print $obj->Hello; /* Shouldn't print out anything */
//print $obj->Bar; /* Shouldn't print out anything */
//print $obj->Foo; /* Shouldn't print out anything */
$obj->printHello(); /* Should print */
Accessing protected variable cause the output fail, why?
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=26260&edit=1