Effisient Set property of Class in PHP

See the piece of cake code below:

class objectInfo {

// class constructor
function objectInfo($object_array) {
reset($object_array);
while (list($key, $value) = each($object_array)) {
$this->$key = tep_db_prepare_input($value);
}
}
}

when we make an instance (object) from the class, we must input parameter of array (better from mysql_query) then we could get the instance property automatically
Efficient, Right?? I've got this code and understanding it from OsCommerce.. Nice programmer code, i'm still learning you know...

Komentar

Postingan Populer