I have been using arrays to store related fields during a long time. If I wanted to have related user fields, I used:
$user = array(
'id' => 27
'name' => 'Pepe'
);
But lately, I've been working a lot with objects, and I like it more to use $user->id instead of $user['id'].
My question: To achieve an object oriented style, you may use stdClass:
$user = new stdClass();
$user->id = 27;
$user->name = 'Pepe';
or casting from an array
$user = (object) array(
'id' => 27
, 'name' => 'Pepe'
);
Is one of them better than the other, in order of performance and style, or can you use whatever you want indistinctly?
Thanks!
Update: I agree with all the comments, this is not OOP at all, is just about having related data grouped into a structure. My $user example is not the best, because it's a typical example of using classes with method, properties, blablabla... I asked because I have a lot of config structures, such us "initTable", and I want something like:
$table => page => init => 1
=> end => 25
sort => field => name
=> order => asc
and so on, and I want to know what is better to get init page:
$table->page->init **OR** $table['page']['init']