News Feed
Sections




News Archive
Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Evert Pot's Blog:
PHP Arrays vs. Objects
August 17, 2007 @ 10:27:00

Wanting to test out a new way of doing things, Evert Pot decided to write up some tests using a Value Object style of data storage versus just in arrays:

In a lot of cases arrays are used in PHP to store object-like information, like the results of a database query. I do this a lot too, but I kind of want to change things around to make use of VO's. I feel this makes a lot more sense, since most of the application I build are heavy OOP anyway, and I get all the added OOP benefits, like type-hinting, inheritance.. well, you know the deal.

In his tests he creates an array of data, a value block of three "properties", looped 1000 times) and a block of three actual properties on an object. Between each, he's using the XDebug memory usage functions to check to see which uses less resources.

Overall, there's really not that much of a difference between using either of them. So, basically, it's up to you which storage method is the simplest for you to use.

0 comments voice your opinion now!
array object memoery usage property storage method array object memoery usage property storage method


blog comments powered by Disqus

Similar Posts

The Bakery: Some ideas to organize your CSS files and autoload them in CakePHP

KillerPHP.com: PHP Design Patterns - when should they be used?

Cocoliso's Blog: Adding A Syntax Highlighter To Your Site: The Power Of Geshi

Mike Naberezny\'s Blog: Fluent Interfaces in PHP

Pádraic Brady's Blog: Complex Views with the Zend Framework - Part 4: The View Factory


Community Events





Don't see your event here?
Let us know!


unittest library framework release api introduction series bugfix deployment community podcast language voicesoftheelephpant symfony zendserver opinion install laravel package interview

All content copyright, 2014 PHPDeveloper.org :: info@phpdeveloper.org - Powered by the Solar PHP Framework