Home >Backend Development >PHP Tutorial > 递归验证用户输入有关问题

递归验证用户输入有关问题

WBOY
WBOYOriginal
2016-06-13 12:48:06788browse

递归验证用户输入问题

<br />
	function checkenter($canshu){<br />
	        //验证输入<br />
		$obj = new base($canshu);<br />
		$re1 = $obj->list_tables($canshu);<br />
			<br />
		//如果验证不通过<br />
                if($re1 === false){<br />
			echo "The '$canshu' was not found, Please input again \n";<br />
			//再次要求输入<br />
                        $canagin = enter();<br />
			//递归验证<br />
                        checkenter($canagin);<br />
		}<br />
		return $canshu;<br />
		<br />
	}<br />
       $result = checkenter($canshu);<br />
	var_dump( $result);

请问,如果第一次输入成功,通过验证,那return $canshu;没问题;但请问在递归里,我怎么得到最后输入成功的值?谢谢了


------解决方案--------------------
不是 return checkenter($canagin); 么?
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn