|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2003-10-19 03:45 UTC] kyle at putnamcabinets dot com
Description:
------------
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] =>
)
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Dec 04 19:00:01 2025 UTC |
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 )