Whats is the difference between -> and [''] in php -


this question has answer here:

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

Popular posts from this blog

android - net_scheduler holding wakelock -

sql - MySQL : Getting Entries from a many-to-many table -

java - Retrieving data from database using jsp (Hibernate + Spring + Maven) -