defining an initial variable in a new object in php -


i new oop forgive me if question flawed.

i writing class fetch , populate data set, performed within loop, return series of index id's populate data of object. within app, need both in loop, , individually. question when (inside or outside loop) initiate class, how define id particular object's item id, used class's methods?

$object = new item($itemid); // or $object = new item->4; // ? 

i not sure how this, or if proper way handle kind of logic.

sidenote

i writing class under assumption first object collection of commonly used functions exist such, trying clean things up.

you need initialize class, , set item id.

$object = new item(); $object->item_id = 1; 

Comments

Popular posts from this blog

php - Why I am getting the Error "Commands out of sync; you can't run this command now" -

ruby - Nesting modules inside of a Rails eninge gem -

Eclipse formatter for java ending braces -