|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #25908 Inherited class properties aren't inherited until after class is parsed [?]
Submitted: 2003-10-19 03:45 UTC Modified: 2003-10-19 08:12 UTC
From: kyle at putnamcabinets dot com Assigned:
Status: Not a bug Package: Class/Object related
PHP Version: 5* OS: *
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Bug Type:
From: kyle at putnamcabinets dot com
New email:
PHP Version: OS:


 [2003-10-19 03:45 UTC] kyle at putnamcabinets dot com
Not sure if this is a bug, but certainly strange behavior. When class properties are mentioned in a function they are created even if the function is not called

Reproduce code:
php5 -n -r 'class frog { function croak() { echo $this->ribbit; } } $f = new frog; print_r($f);'

Expected result:
frog Object

Actual result:
frog Object
    [ribbit] =>


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2003-10-19 04:03 UTC] kyle at putnamcabinets dot com
This also causes some undesired behavior (aside from being strange):

kputnam@linus:~$ php5 -n -r '
> class thing
> {
>   protected $ribbit = 'ZOINKS';
> }
> class frog extends thing
> {
>   function croak()
>   {
>     echo $this->ribbit;
>   }
> }
> $f = new frog;
> print_r($f);'

frog Object
    [ribbit] =>
    [ribbit:protected] => ZOINKS
 [2003-10-19 04:58 UTC]
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at and the instructions on how to report
a bug at

Duplicate of #25815, 25199
 [2003-10-19 08:12 UTC]
Also update your php source. The visibility problem you described in your second comment is fixed already.
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Apr 23 17:01:31 2024 UTC