语法错误,意外的"if"(T_IF) [英] syntax error, unexpected 'if' (T_IF)
本文介绍了语法错误,意外的"if"(T_IF)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想我一直盯着这个问题已经太久了,以至于现在我无法发现问题所在.
I think I've been staring at this for too long that now I'm failing to identify the problem.
有人可以指出这是哪里出了问题吗?
Can someone kindly point out where this is going wrong?
错误:
Parse error: syntax error, unexpected 'if' (T_IF) in /Applications/MAMP/htdocs/mipbi/includes/classes/html.php on line 11
代码:
public static function textbox($name, $maxlength=''){
return "<input type='text' id='$name' name='$name' maxlength='$maxlength' value='". if (isset($_POST[$name])) { echo $name; } ."' >";
}
在if语句行生成错误.
The error is generated at the if statement line.
推荐答案
您不能使用if语句.
要完成您想实现的目标,您需要这样做:
To do what you want to achieve you'll need to do this:
public static function textbox($name, $maxlength=''){
return "<input type='text' id='$name' name='$name' maxlength='$maxlength' value='".(isset($_POST[$name]) ? $name : '')."' >";
}
这篇关于语法错误,意外的"if"(T_IF)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文