News Feed
Sections




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

CodeUtopia Blog:
Generic collections in PHP
September 19, 2008 @ 12:06:53

On the CodeUtopia blog Jani Hartikainen has posted some thoughts on generic collections in PHP and a class he's created to try to introduce them to the language.

Strictly typed languages usually use "generic" collection classes instead of arrays. They are kind of like PHP arrays which the programmer can tell which type of items to accept. This is of course only natural when you don't have dynamic typing, but it can also be useful for avoiding programming errors, so I thought I'd try making a basic generic collection class in PHP...

He shows how ti works with a simple code example - creating a new collection type (a string) and pushing the data into it. Calling the add() method on the string throws an exception because of the data type defined. You can grab the code from his svn repository.

0 comments voice your opinion now!
generic collection class download svn example string


blog comments powered by Disqus

Similar Posts

php|architect: MTA announces new ZFCE training course and exam simulator

Benjamin Eberlei: Feature Flags and Doctrine Entities

Zend Developer Zone: Improved Test Assets for Zend_Tool Generated Projects in ZF 1.11.4

Rob Richards' Blog: WS-Addressing for ext/soap

PHP.net: PHP 5.6.0RC1 is available


Community Events

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


voicesoftheelephpant version podcast laravel library introduction series interview threedevsandamaybe unittest security community opinion api release extension laravel5 framework symfony language

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