From: chongwh at yahoo dot com
Operating system: winxp
PHP version: 5.0.0b2 (beta2)
PHP Bug Type: Output Control
Bug description: Example In Changes in PHP 5/Zend Engine 2.0
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 bug report at http://bugs.php.net/?id=26260&edit=1
--
Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=26260&r=trysnapshot4
Try a CVS snapshot (php5): http://bugs.php.net/fix.php?id=26260&r=trysnapshot5
Fixed in CVS: http://bugs.php.net/fix.php?id=26260&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=26260&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=26260&r=needtrace
Try newer version: http://bugs.php.net/fix.php?id=26260&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=26260&r=support
Expected behavior: http://bugs.php.net/fix.php?id=26260&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=26260&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=26260&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=26260&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=26260&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=26260&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=26260&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=26260&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=26260&r=float