DISCOVER
X

Which One Uses Less Memory in PHP? Objects or Arrays?

March 13, 2013 8:50 am Leave your thoughts
Facebooktwittergoogle_plusredditpinterestlinkedinmailFacebooktwittergoogle_plusredditpinterestlinkedinmail

Many times this question pops in my mind and many others. Obviously if it’s more to do with representing objects such as a car or a person, then we use objects as it’s a more “proper” way of doing it. However if we just want to keep a set of data in a container represented by key – value representative, which one are we going to use?

So either:

OR

The answer is objects, in general uses less memory than array.

Head to the this great gist about what PHP do internally with objects.

https://gist.github.com/nikic/5015323

Facebooktwittergoogle_plusredditpinterestlinkedinmailFacebooktwittergoogle_plusredditpinterestlinkedinmail
Tags: , ,

Categorised in: ,