Hi,
I have a problem where I am getting the following error, and I was
wondering if anyone has seen this one before and can help me out.
"Fatal error: Cannot redeclare isvalidphonenumber() (previously
declared in /home/bluekomo/public_html//classes/Registrant.class:360)
in /home/bluekomo/public_html//classes/Registrant.class on line 360"
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?
Here is the relevant section of code:
354 /**
355 * sets the phone property
356 */
357 function setPhone($phone) {
358 // TODO: determine if these formats are acceptable
359 // TODO: account for extensions (separate form field?)
360 function isValidPhoneNumber($num) {
361 $valid = false;
362 if (preg_match('!\d{9,9}!', $num)) {
363 $valid = true;
364 }
365 if (preg_match('!\(?\d\d\d\)?-?\s*\d\d\d-?\s*\d\d\d\d!',
366 $num)) {
367
368 $valid = true;
369 }
370
371 return $valid;
372 }
373
374 if (isValidPhoneNumber($phone)) {
375 $this->phone = $phone;
376 }
377 }
I am using PHP 4.3.0 on a RedHat machine with Apache 1.3.x.
Thanks for your help, it's been a while since I've used PHP!
Erik
--
Erik Price
email: [EMAIL PROTECTED]
jabber: [EMAIL PROTECTED]
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
- [PHP] Re: function getting redeclared Erik Price
- [PHP] Re: function getting redeclared Greg Beaver
- RE: [PHP] function getting redeclared Ford, Mike [LSS]
- Re: [PHP] function getting redecla... Erik Price