Re: function doesn't return value

From: Date: Sat, 28 Jun 2003 19:36:56 +0000
Subject: Re: function doesn't return value
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-153282@lists.php.net to get a copy of this message
On Sunday 29 June 2003 02:53, anders thoresson wrote: > After a new user has filled in a form to register for my site, I check > that she has entered the same password twice by calling a homemade > function. Like this: > > $u_pwd = validate_password($_POST['u_pwd'],$_POST['u_pwd1']); > > And the function looks like this: > > function validate_password($unchecked_password1, $unchecked_password2, > $errortype = 1, $errormessage = "Password must contain just letters and > figures.") { > > if(!($unchecked_password1 == $unchecked_password2)) { > error("Passwords entered doesn't match!"); > } > > if(!ereg("(^[a-zA-ZåÅäÄöÖ0-9]{6,15}$)", $unchecked_password2)) { > if($errortype == 1) { > error($errormessage); > } > Return 1; > } > > } > > I have verified that $_POST['u_pwd'] and $_POST['u_pwd1'] as well as > $unchecked_password1 and $unchecked_password2 contains the entered values, > but $u_pwd is empty. > > Why? AFAIK in PHP, if you don't specifically return something from a function, the function will not return anything. -- Jason Wong -> Gremlins Associates -> www.gremlins.biz Open Source Software Systems Integrators * Web Design & Hosting * Internet & Intranet Applications Development * ------------------------------------------ Search the list archives before you post http://marc.theaimsgroup.com/?l=php-general ------------------------------------------ /* Smear the road with a runner!! */

« previous php.general (#153282) next »