"stdClass" is an void class of PHP. It can be as a act of the alternative of a associative array but works only on PHP 5 and more Any associative array.
You thought it of a object as same in java or python.
$info = array("question" => "school of", "answer" =&>100);
$ic = (object) $info;
print $ic->answer . "\n";
print $ic->question . "\n";
The result shown like this
100
school of
If you want to see what that looks like inside:
$cando = get_object&_vars($ic);
var_dump($cando);
which gives me:
array(2) {
["question"]=> string(4) "school of"
["answer"]=>
int(100)
}
Now the 'stdClass' comes with an extra feature like you can scale and fir more character and behaviours in it.
class thing extends stdClass {
public function assign($key , $value = false) {
$this->$key = $value;
}
public function getpairs() {
$pointer = get_object_vars($this);
return $pointer;
}
}
And let's now make some used of that:
$story = new thing();
$story->draw("in","Canvas");
$story->ended = "morning";
print $story-> . "\n";
print $story->draw . "\n";
print "--\n";
$about = $story->getpairs();
foreach (array&_keys($about) as $k) {
print ("$k - $about[$k]\n");
}
The output of code will be like this
Canvas
morning
-----
in - Canvas
ended - morning
0 Comment(s)