form表单提交后提示 Undefined variable

WBOY
Release: 2016-06-23 13:26:28
Original
1807 people have browsed it

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


回复讨论(解决方案)

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

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

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

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

原来如此 谢谢啦

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