php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #26260 Example In Changes in PHP 5/Zend Engine 2.0
Submitted: 2003-11-15 08:24 UTC Modified: 2003-11-15 13:34 UTC
From: chongwh at yahoo dot com Assigned:
Status: Not a bug Package: Output Control
PHP Version: 5.0.0b2 (beta2) OS: winxp
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
31 + 24 = ?
Subscribe to this entry?

 
 [2003-11-15 08:24 UTC] 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?


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-11-15 13:34 UTC] iliaa@php.net
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.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Mar 29 11:01:29 2024 UTC