Home >Backend Development >PHP Tutorial >form表单提交后提示 Undefined variable

form表单提交后提示 Undefined variable

WBOY
WBOYOriginal
2016-06-23 13:26:281824browse

表单提交之后提示num_tries变量未定义,可是明明在第3行就定义了啊


回复讨论(解决方案)

第三行改一下:(int)强制类型转换的对象应该是$_POST吧。。。

$num_tries = (isset($_POST['num_tries'])) ? ((int)$_POST['num_tries']+1) : 1;

第 3 行应为
$num_tries = (isset($_POST['num_tries'])) ? $_POST['num_tries']+1 : 1;
不需要强制类型转换

+1之后确实不需要强制类型转换。。其实用(int)强转和intval()转换为数字不如直接+一个数

原来如此 谢谢啦

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
Previous article:请假下各位php表单问题Next article:图片缓存的问题