CodeIgniter Forums
What is the meaning of std Class object ... + array - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21)
+--- Thread: What is the meaning of std Class object ... + array (/showthread.php?tid=41105)



What is the meaning of std Class object ... + array - El Forum - 04-28-2011

[eluser]phpfresher[/eluser]
Need some suggestions????


What is the meaning of std Class object ... + array - El Forum - 04-28-2011

[eluser]WanWizard[/eluser]
need some more info????


What is the meaning of std Class object ... + array - El Forum - 04-28-2011

[eluser]CroNiX[/eluser]
Just guessing, but you are probably trying to iterate over an object or accessing its properties as if it were an array using array notation instead of object notation.

Like, if $my_object is an object with a property of 'setting' and you are trying to access it like $my_object['setting'] instead of $my_object->setting.


What is the meaning of std Class object ... + array - El Forum - 04-29-2011

[eluser]Sire[/eluser]
A common issue I've seen is the reverse of CroNIX's comment, "Creating default object from empty value"

An example where I've seen this is in the WordPress includes, user.php. An example:
Code:
$blog_id = get_current_blog_id();
        $blogs = array();
        $blogs[ $blog_id ]->userblog_id = $blog_id;

The solution is to create the default object first
Code:
$blog_id = get_current_blog_id();
        $blogs = array();
        $blogs[ $blog_id ] = new stdClass();  // this was added
        $blogs[ $blog_id ]->userblog_id = $blog_id;