Whats is the difference between -> and [''] in php -
this question has answer here:
- reference — symbol mean in php? 15 answers
i have been following 2 ways data array..sometimes use
$username= $data['username']; $first_name= $data['first_name'];
and sometimes,
$username= $data->username; $first_name= $data->first_name;
anytime have array, know 1 of them work, , works..
but unable understand difference between them, never sure 1 use.
i google lot unable find explanation.
kindly guide me
thanks
that's misconception.
the upper syntax square brackets work arrays (or objects implementing arrayaccess
).
the lower syntax using t_object_operator
work on objects. cannot access arrays that.
compare following links in php manual:
Comments
Post a Comment