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

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -