I am trying to get a class working but for some reason I cannot get find the variables I have built into the class. Here is the code for the class: class file url (cls_question_object.php)
class question_object{
// the id to the question
public $i_id = "";
// the question string
public $s_qString = "";
// the question type
public $s_qType = "";
/* the array of answer strings
*/
public $a_qAnswerStrings = array();
public $a_qAnswerSet = array("id"=>"","string"=>"");
}
And here is the code that I am testing my class with: file url (test_question_object.php)
include("cls_question_object.php");
/* - test for class question object -
*/
$cls_obj = new question_object;
$cls_obj->$i_id = "1";
$cls_obj->$s_qString = "test question string";
$cls_obj->$s_qType = "fib";
$cls_obj->$$a_qAnswerStrings[0]['id'] = "0";
$cls_obj->$$a_qAnswerStrings[0]['string'] = "test answer string";
print_r($cls_obj);
Here is the error I am getting:
Notice: Undefined variable: i_id in C:\wamp\www\Exam Creator\test_question_object.php on line 9
i_for integers ors_for strings. That is an incredibly out-dated practice, and has particularly little value in PHP where the type of a variable can and will change to suit its use. You're only going to produce ugly, difficult to maintain code this way.