Re: Error while calling a function
| From: | Steve Cayford | Date: | Tue, 18 Dec 2001 20:50:01 +0000 |
| Subject: | Re: Error while calling a function | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-78126@lists.php.net to get a copy of this message | ||
I don't know all the details about how PHP compiles a program, but having your function definitions in an if-else statement that may not be executed looks suspicious to me.
You've got
if(!$Phone)
{
do something} else {
function is_phone() { ...blah, blah...}
}
is_phone($Phone);
If you don't hit the else block, your is_phone function is probably not defined.
-Steve
On Tuesday, December 18, 2001, at 07:26 AM, J.F.Kishor wrote:
hi all, I have got a problem, when I execute the following script it gives a Fatal error, could any one tell me why is it ?, If this is a silly problem please execuse me but, plz do reply me. The script is ------------- <html> <body> <? if(!$Phone) { ?> <form action="<?echo $PHP_SELF?>" method=post><br> Telephone Number : <input type=text name=Phone value=""><br> <input type=submit> <script language="php"> } else { function is_allnumbers ($text){ if( (gettype($text)) == "integer"){ print "the value is an integer"; return true; }$Bad = $this->strip_numbers($text);if(empty($Bad)){ print "the value is empty"; return true; }return false; }function clear_error (){ $this->ERROR = "this is an error"; }function is_phone ($Phone =""){ if($this->CLEAR){ $this->clear_error(); }if(empty($Phone)){ $this->ERROR = "is_phone: No Phone number submitted"; return false; }$Num = $Phone; $Num = $this->strip_space($Num); $Num = eregi_replace("(\(|\)|\-|\+)","",$Num); if(!$this->is_allnumbers($Num)){ $this->ERROR = "is_phone: bad data in phone number"; return false; }if ( (strlen($Num)) < 7){ print "the number is less then 7"; $this->ERROR = "is_phone: number is too short [$Num][$Phone]"; return false; }if( (strlen($Num)) > 13){ print "the number is > then 13"; $this->ERROR = "is_phone: number is too long [$Num][$Phone]"; return false; }return true; }} $result = is_phone($Phone); if($result == "true") {echo "success";} else { echo "failure"; } </script> </body> </html> The error is ------------ Fatal error: Call to undefined function: is_phone() in /home/kuruvi1/kishor/public_html/IMS/ADMIN/test/is_phone.php on line 87 Thanks for your tolerance, - JFK kishor -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net For additional commands, e-mail: php-general-help@lists.php.net To contact the list administrators, e-mail: php-list-admin@lists.php.net