RE: [PHP] function getting redeclared
| From: | Ford, Mike [LSS] | Date: | Tue, 18 Feb 2003 15:27:03 +0000 |
| Subject: | RE: [PHP] function getting redeclared | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-136021@lists.php.net to get a copy of this message | ||
> -----Original Message-----
> From: Erik Price [mailto:erikprice@mac.com]
> Sent: 18 February 2003 15:14
>
> 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.
Cheers!
Mike
---------------------------------------------------------------------
Mike Ford, Electronic Information Services Adviser,
Learning Support Services, Learning & Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Beckett Park, LEEDS, LS6 3QS, United Kingdom
Email: m.ford@lmu.ac.uk
Tel: +44 113 283 2600 extn 4730 Fax: +44 113 283 3211