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

递归验证用户输入问题

WBOY
Release: 2016-06-23 14:08:24
Original
870 people have browsed it

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

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


回复讨论(解决方案)

不是 return checkenter($canagin); 么?

不是 return checkenter($canagin); 么?
谢谢,是这样的,
当进入递归后checkenter($canagin) 就是函数 checkenter()里的$canshu,是这样理解吧?

虽然已经结贴了,但是错误的做法必须纠正
由于 http 协议的不可重入性,函数 checkenter 不可能出现递归

虽然已经结贴了,但是错误的做法必须纠正
由于 http 协议的不可重入性,函数 checkenter 不可能出现递归
版主大人,这个例子成功了,这是一个php_cli程序,谢谢您.

虽然已经结贴了,但是错误的做法必须纠正
由于 http 协议的不可重入性,函数 checkenter 不可能出现递归

小女子不才,出现了新问题:http://bbs.csdn.net/topics/390444529

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template