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
<?php
include("cls_template.php");
/* START CODE FOR TESTING */
//echo("Required File Included");
/* END CODE FOR TESTING */
/* - cls_fillinthelank -
@author: Brook L. Julias II
@project: Exam Creator
@version: 0.1.7
The class fillintheblank is where all functions and variables having to do
the fill in the blank type question are going to be stored here.
*/
class fillintheblank{
function _construct(){
$cls_blankInput = new template;
$cls_questionString = new template;
$cls_fillInTheBlank = new template;
}
/* Fill in the Blank - Blank Input Template
placeholders: [qInputName], [qInputId], [qInputValue]
- [qInputName] & [qInputId] should be set as an array ('qId_#[]')
*/
if(class_exists($cls_blankInput)){
$cls_blankInput->fillString("<input type='text' name='[qInputName]' id='[qInputId]' value='[qInputValue]' />");
$cls_blankInput->fillPlaceholderStrings(array("[qInputName]","[qInputId]","[qInputValue]"));
} else {
print("\$cls_blankInput not defined.<br>");
}
/* Question String - The Question String with placeholders.
placeholders: [fib_blank]
*/
if(class_exists($cls_questionString)){
$cls_questionString->fillString(""); // to be set later
$cls_questionString->fillPlaceholderStrings(array("[fib_blank]"));
} else {
print("\$cls_questionString not defined.<br>");
}
/* Fill in the Blank - Question Template
placeholders: [qFillInTheBlankString]
*/
if(class_exists($cls_fillInTheBlank)){
$cls_fillInTheBlank->fillString("<li>[qFillInTheBlankString]</li>");
$cls_fillInTheBlank->fillPlaceholderStrings(array("[qFillInTheBlankString]"));
} else {
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_id;
// 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;
}
/* - q_fib_buildString() -
#parameter#
$s_template @type CLASS - (class template)
$s_template->templateString
$s_template->
#returns#
$s_string @type STRING - the question string w/o placeholder
This function will create the string that is the fill in a blank
question with text inputs as the blanks.
There is both a placeholder array, and a value array. The array
key for each matches the attribute that is to be changed in the
input tags.
*/
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_string;
}
}
?>
cls_Template.php
<?php
/* - Class Template -
@author: Brook L. Julias II
@project: Exam Creator
@version: 1.0.1
*/
class template{
public $templateString = ""; // @type STRING
public $placeholder = array(); // @type ASSOCIATTIVE ARRAY
$placeholder["strings"] = array(); // @type ARRAY
$placeholder["values"] = array(); // @type ARRAY
function fillString($templateStr){
$this->templateString = $templateStr;
}
function fillPlaceholderStrings($placeholderStr){
$placeholder_string_array = explode(",",$$placeholderStr);
$this->placeholder["strings"] = $placeholder_string_array;
}
function fillPlaceholderValues($placeHolderValueStr){
$placeholder_value_array = explode($placeHolderValueStr)
$this->placeholder["values"] = $placeholder_value_array;
}
function buildTemplate(){
$builtTemplateString = preg_replace(
$this->placeholder["strings"],
$this->placeholder["values"],
$this->templateString
);
return $builtTemplateString;
}
}
?>