arrays - Benefits of ArrayAccess Interface in PHP? -
implementing arrayaccess interface in php , can access object properties array keys . benefits of having object behave array?
like see frameworks implementing 'form' arrayaccess
interface , can access (html) form objects fields like,
$form['namefield'] instead-of $form->namefield $form['titlefield'] instead-of $form->titlefield
whats benefit of using $form['namefield]
instead-of $form->namefield
is speed of 'array data structures' or portability between object , array forms ?
or missing something? :)
there no functional benefit, structural.
if define map, suggest, can contain arbitrary number of named elements, of similar kinds. object properties defined , of different types.
in short: if implement arrayaccess
"my object (also) behaves array".
Comments
Post a Comment