PHP Memory Usage: The cost of a million objects

Even though memory is getting cheaper, our applications are becoming more complicated and we need to write our code more carefully. I’d like to share some surprising tests I’ve written recently. The sample code files are also on github: https://github.com/muratyaman/php-tips. The tests are very simple: let’s create an array of million items to process: version … Read morePHP Memory Usage: The cost of a million objects

Programming with too many unknowns in a dynamic language

The aim is to write code efficiently, but without compromising easy debugging, maintenance, and especially adaptability to “possible” changes in future. When I first started programming with Fortran (77), which had been used intensively for half a century in scientific and engineering applications, I learned that all variables had types: integer, real, double precision, complex, … Read moreProgramming with too many unknowns in a dynamic language

PHP: magic methods

Regarding __toString

PHP5: Autoloading your magic!

__autoload() function can be very useful to optimize your code esp. when you have so many classes. Unlike class extensions, optional parameters with class restrictions may not load your class.

So, it’s very encouraging to use classes everywhere! Even encapsulating your functions inside simple classes to use like static modules, will help a lot! … Read morePHP5: Autoloading your magic!