Parse error:js syntax errorr, unexpected T_ELSEIF

Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.
Parse error: syntax error, unexpected T_IF, expecting T_FUNCTION in C:\wamp\www\Exam Creator\cls_FillInTheBlank.php on line 31
I received this error while trying to run the cls_FillInTheBlank.php which includes cls_template.php. I have the two files posted at the for review.
cls_FillInTheBlank.php
include("cls_template.php");
class fillintheblank{
function _construct(){
$cls_blankInput =
$cls_questionString =
$cls_fillInTheBlank =
if(class_exists($cls_blankInput)){
$cls_blankInput-&fillString("&input type='text' name='[qInputName]' id='[qInputId]' value='[qInputValue]' /&");
$cls_blankInput-&fillPlaceholderStrings(array("[qInputName]","[qInputId]","[qInputValue]"));
print("\$cls_blankInput not defined.&br&");
if(class_exists($cls_questionString)){
$cls_questionString-&fillString("");
// to be set later
$cls_questionString-&fillPlaceholderStrings(array("[fib_blank]"));
print("\$cls_questionString not defined.&br&");
if(class_exists($cls_fillInTheBlank)){
$cls_fillInTheBlank-&fillString("&li&[qFillInTheBlankString]&/li&");
$cls_fillInTheBlank-&fillPlaceholderStrings(array("[qFillInTheBlankString]"));
print("\$cls_fillInTheBlank not defined.&br&");
public function q_fib_buildString($cls_question){
$i_qID = "";
// @type INTEGER
$s_html = "";
// @type STRING
$a_inputs = "";
// @type ARRAY
$s_innerHTML = "";
// @type STRING
$s_outerHTML = "";
// @type STRING
$i_qID = $cls_question-&qo_i_
// build the HTML for the blank input
foreach($cls_question-&qo_a_answerSet as $answer){
$this-&cls_blankInput-&fillPlaceholderValues(array("qID_".$i_qID,"qID_".$i_qID,$answer["value"]));
$a_inputs[count($a_inputs)] = $this-&cls_blankInput-&buildTemplate();
// build the inner HTML
$this-&cls_questionString-&fillString($cls_question-&qo_s_string);
$this-&cls_questionString-&fillPlaceholderValues($a_inputs);
$s_innerHTML = $this-&cls_blankInput-&buildTemplate();
// build the outer HTML
$this-&cls_fillInTheBlank-&fillPlaceholderValues($s_innerHTML);
$outerHTML =
$this-&cls_fillInTheBlank-&buildTemplate();
return $outerHTML;
public function q_fib_buildString($s_template){
$s_fib_patterns = array();
$s_input_blank = "";
$s_fib_patterns_blank = "[\[fib_blank\]]";
// array of placeholders
$a_fib_patterns['input'] = array();
// place holder for the name attribute of the input tag
$a_fib_patterns['attribute']['name'] ="[\[qInputName\]]";
// place holder for the id attribute of the input tag
$a_fib_patterns['attribute']['id'] = "[\[qInputId\]]";
// array of values
$a_fib_replace['value'] = array();
// value for the name attribute
$a_fib_replace['value']['name'] = "qId_".$i_id."[]";
// value fo the id attribute
$a_fib_replace['value']['id'] = "qId_".$i_id."[]";
// build blank input
$s_input_blank = preg_replace($a_fib_patterns['input'],$a_fib_replace['value'],fillintheblank::$s_blankInput);
// build question string
$s_string = preg_replace($s_fib_patterns_blank,$s_input_blank,$s_string);
/* START CODE FOR TESTING */
echo($s_input_blank);
// echo code for the blank inputs
/* END CODE FOR TESTING */
// return question string
return $s_
32.6k1083105
You've basically got this:
class fillintheblank {
if (...) {
if (...) {
That's not permitted. A class definition has member variables and method definitions (ie: functions). You can't put "naked" PHP code in a class definition. YOu'll have to wrap it in a method, probably a constructor.
214k17136244
Your problem is you started a class, but then you started writing what would usually be found in a function body in it. You need to enclose lines 27-56 in a function definition.
Also, unrelatedly, you named a method _construct when you probably meant __construct. Two underscores, not just one.
66.3k8104140
Your Answer
Sign up or
Sign up using Google
Sign up using Facebook
Sign up using Stack Exchange
Post as a guest
Post as a guest
By posting your answer, you agree to the
Not the answer you're looking for?
Browse other questions tagged
Stack Overflow works best with JavaScript enabledphp Parse error: syntax error, unexpected T_VARIABLE 错误
[问题点数:10分,结帖人sqjxjs]
php Parse error: syntax error, unexpected T_VARIABLE 错误
[问题点数:10分,结帖人sqjxjs]
不显示删除回复
显示所有回复
显示星级回复
显示得分回复
只显示楼主
相关帖子推荐:
2013年5月 总版技术专家分月排行榜第一
2014年8月 总版技术专家分月排行榜第二2014年7月 总版技术专家分月排行榜第二2013年6月 总版技术专家分月排行榜第二
2005年1月 PHP大版内专家分月排行榜第三2007年8月 PHP大版内专家分月排行榜第三
本帖子已过去太久远了,不再提供回复功能。58cv网址导航Parse error: syntax error, unexpected T_IF in 的问题 期望高手解决
[问题点数:40分]
Parse error: syntax error, unexpected T_IF in 的问题 期望高手解决
[问题点数:40分]
不显示删除回复
显示所有回复
显示星级回复
显示得分回复
只显示楼主
相关帖子推荐:
2010年11月 PHP大版内专家分月排行榜第二2010年10月 PHP大版内专家分月排行榜第二2010年7月 PHP大版内专家分月排行榜第二2009年8月 PHP大版内专家分月排行榜第二
2010年6月 PHP大版内专家分月排行榜第二
2010年8月 PHP大版内专家分月排行榜第三
2010年8月 PHP大版内专家分月排行榜第二
2010年7月 PHP大版内专家分月排行榜第三
本帖子已过去太久远了,不再提供回复功能。PHP错误解析器代号列表
PHP 语言的不同部分在内部被表示为类似 T_SR 的类型。PHP 在解析错误时输出这样的标识符,例如&Parse error: unexpected T_SR, expecting &,& or &;& in script.php on line 10.&。
应该知道 T_SR 的含义。对于所有不知道的人,下表列出了这些标识符,PHP 语法和在手册中适当位置的参考。
代号语法参考
T_ABSTRACT
抽象类(自 PHP 5.0.0 起可用)
T_AND_EQUAL
赋值运算符
array(),数组语法
T_ARRAY_CAST
T_BAD_CHARACTER
在 ASCII 32 之前除了 \t (0&09), \n (0&0a) 和 \r (0&0d) 以外的任何字符
T_BOOLEAN_AND
逻辑运算符
T_BOOLEAN_OR
逻辑运算符
T_BOOL_CAST
(bool) 或 (boolean)
异常处理(自 PHP 5.0.0 起可用)
T_CHARACTER
类和对象。仅用于 PHP 5。
T_CLOSE_TAG
// 或 #,以及 PHP 5 下的 /* */
T_CONCAT_EQUAL
赋值运算符
T_CONSTANT_ENCAPSED_STRING
&foo& 或 &bar&
字符串语法
T_CONTINUE
T_CURLY_OPEN
递增/递减运算符
T_DIV_EQUAL
赋值运算符
0.12,等等
T_DOC_COMMENT
PHPDoc 风格的注释(仅用于 PHP 5)
T_DOLLAR_OPEN_CURLY_BRACES
复杂变量解析语法
T_DOUBLE_ARROW
T_DOUBLE_CAST
(real), (double) 或 (float)
T_DOUBLE_COLON
见下面的&T_PAAMAYIM_NEKUDOTAYIM
T_ENCAPSED_AND_WHITESPACE
T_ENDDECLARE
enddeclare
declare,替代语法
for,替代语法
T_ENDFOREACH
endforeach
foreach,替代语法
if,替代语法
T_ENDSWITCH
switch,替代语法
T_ENDWHILE
while,替代语法
T_END_HEREDOC
heredoc 语法
exit 或 die
exit(), die()
extends,类和对象
Final关键字(自 PHP 5.0.0 起可用)
T_FUNCTION
function 或 cfunction
T_HALT_COMPILER
__halt_compiler()
__halt_compiler(自 PHP 5.1.0 起可用)
T_IMPLEMENTS
implements
接口(自 PHP 5.0.0 起可用)
递增/递减运算符
T_INCLUDE_ONCE
include_once()
include_once()
T_INLINE_HTML
T_INSTANCEOF
instanceof
type operators(仅 PHP5)
T_INT_CAST
(int) 或 (integer)
T_INTERFACE
接口(自 PHP 5.0.0 起可用)
T_IS_EQUAL
比较运算符
T_IS_GREATER_OR_EQUAL
比较运算符
T_IS_IDENTICAL
比较运算符
T_IS_NOT_EQUAL
比较运算符
T_IS_NOT_IDENTICAL
比较运算符
T_IS_SMALLER_OR_EQUAL
比较运算符
123,012,0&1ac,等等
T_LOGICAL_AND
逻辑运算符
T_LOGICAL_OR
逻辑运算符
T_LOGICAL_XOR
逻辑运算符
T_MINUS_EQUAL
赋值运算符
T_ML_COMMENT
注释(仅用于 PHP 4)
T_MOD_EQUAL
赋值运算符
T_MUL_EQUAL
赋值运算符
T_NUM_STRING
T_OBJECT_CAST
T_OBJECT_OPERATOR
T_OPEN_TAG
&?php, &? 或 &%
从 HTML 转义
T_OPEN_TAG_WITH_ECHO
&?= or &%=
从 HTML 转义
T_OR_EQUAL
赋值运算符
T_PAAMAYIM_NEKUDOTAYIM
::。也定义为&T_DOUBLE_COLON。
T_PLUS_EQUAL
赋值运算符
类和对象。仅用于 PHP 5。
类和对象。仅用于 PHP 5。
T_PROTECTED
类和对象。仅用于 PHP 5。
T_REQUIRE_ONCE
require_once()
require_once()
T_SL_EQUAL
赋值运算符
T_SR_EQUAL
赋值运算符
T_START_HEREDOC
heredoc 语法
T_STRING_CAST
T_STRING_VARNAME
异常处理(自 PHP 5.0.0 起可用)
异常处理(自 PHP 5.0.0 起可用)
T_UNSET_CAST
(无文档; 类型为&NULL)
(未实现)
T_VARIABLE
while,do..while
T_WHITESPACE
T_XOR_EQUAL
赋值运算符
__FUNCTION__
常量,自 PHP 4.3.0 起可用
常量,自 PHP 4.3.0 起可用
阅读(...) 评论()}

我要回帖

更多关于 tcpdump syntax error 的文章

更多推荐

版权声明:文章内容来源于网络,版权归原作者所有,如有侵权请点击这里与我们联系,我们将及时删除。

点击添加站长微信