PhpRiot
News Archive
PhpRiot Newsletter
Your Email Address:

More information

Struct classes in PHP

Note: This article was originally published at Planet PHP on 24 January 2011.
Planet PHP
PHP arrays are a wonderful tool and one of the reasons I like PHP. Their versatility makes it possible to easily set up proof of concepts (POV), either used as hash maps storing multiple keys, or as lists, stacks, trees or whatever you like. But once you are past the phase of the initial POC, the excessive usage of arrays and exactly their versatility has some drawbacks: If you see an array type hint or return documentation, you know nearly nothing about the data structure. Using arrays as key-value hash maps for storing configuration keys or data sets you also know nearly nothing about the expected contents of the array.