Re: function getting redeclared

From: Date: Tue, 18 Feb 2003 16:51:20 +0000
Subject: Re: function getting redeclared
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-136032@lists.php.net to get a copy of this message
On Tuesday, February 18, 2003, at 10:27 AM, Ford, Mike [LSS] wrote:
I have a script, "registration.php", which calls require_once on the Registrant.class file mentioned in the above error message. The Registrant::setPhone() method is called more than once. Since it is called more than once, the function "isValidPhoneNumber()" defined within setPhone() is defined more than once, which I suspect is the source of the problem. Does PHP not allow you to define a function within a function and then call the enclosing function more than once?
Well, it kinda does, but as it doesn't limit the scope in any way there's not really any point. Besides, it can lead to the kind of problems you're experiencing. Just declare the two functions sequentially in your include file.
Okay, so PHP stores all functions that are not class methods in a global namespace? Or does it even do this with methods? Just curious so I don't depend on anything I'm used to from other languages.... thanks! Erik -- Erik Price email: erikprice@mac.com jabber: erikprice@jabber.org

« previous php.general (#136032) next »