I have the the following code in a script that I am learning from and I tried echoing or printing the variable thinking it is an array but apparently that doesn't work.
The full code goes something like this
$i = new b();
$i->c = "d";
$i->e = "f";
$i->g = "h";
$i->j = "k";
$i->l = "m";
I have tried echoing and printing the variable $i but thinking it might be an array but it does not work, while returning a Fatal Error saying that the class 'b' was not found.
The new b()
part creates a new instance of class b
. It would be an object, not an array, if a class named b
was defined elsewhere in your source code. The other lines assign some strings to properties of that object.
You can read more about object oriented programming in PHP in the manual.
You might find the var_dump function useful in the future.
This code instantiates a new object $i
from a (apparently non-existent) class b
and sets several object properties.
Please read the introduction to Object Oriented Programming for more.
$i = new b();
Instantiate a new object named $i
from class b
$i->c = "d";
Assign object $i
's member c the string value "d
"