note 36011 added to functions

From: Date: Mon, 22 Sep 2003 21:43:43 +0000
Subject: note 36011 added to functions
Groups: php.notes 
Request: Send a blank email to php-notes+get-56926@lists.php.net to get a copy of this message
I could be missing a basic principle here, but I thought I'd point this out, as the behavior is far from what I would expect... Hope it helps. A lil' bug(?) I seemed to notice is that if you declare a function within a class method, the function becomes globally available, rather than availble through the class... <?php Class Lame { function Lame() { print "I am the constructor."; } function foo() { function bar() { print "I am BAR.\n"; } print "I am FOO.\n"; } } $lame = new Lame; $lame->foo(); // now "bar" exists. $lame->bar(); // doesn't work. bar(); // works! Weird. ?> ---- Manual Page -- http://www.php.net/manual/en/functions.php Edit Note -- http://master.php.net/manage/user-notes.php?action=edit+36011 Delete Note -- http://master.php.net/manage/user-notes.php?action=delete+36011&report=yes Reject Note -- http://master.php.net/manage/user-notes.php?action=reject+36011&report=yes

« previous php.notes (#56926) next »