A comment thread about variable variables

Before you go reading this comment thread (link below) be aware that just because something is possible in a programming language, it doesn’t mean you should do things that way.  Also, there’s a LOT of BAD code in the main post.

masklinn comments on Today I learned about PHP variable variables; “variable variable takes the value of a variable and treats that as the name of a variable”. Also, variable..

[The following is the opinion of Gordon, not necessarily AzPHP as a whole]

Personally, I avoid variable variables like the plague.  If you feel the need to use one, step back and see if you can use an associative array instead.  You will thank me later.  An array structure is much easier to deal with than a bunch of unlinked funky-named variables that you have to rebuild each time you need them.  Arrays are increasingly useful if you have to loop through said data structures or easily store them.

Variable variables are both powerful and a curse.  Use them if you feel you must, but I only ask that you use them wisely.

PHP Object Oriented Programming Reinvented and Serializing Closures

Pretty bizarre…the idea is to programmatically create, extend, and modify objects directly from your code at run time instead of pre-creating your classes.  Not saying it’s good or bad, just different.  And yes, he does know the acronym is unfortunate.


Related, someone figured a way to serialize closures into objects using reflection files.


Javascript print_r()

Many of us have searched for a looooong time to find something like this that works. My coworker found something that almost worked, but failed horribly, so I fixed it and here it is for your viewing/usage enjoyment. Note that it requires jQuery.

… Hmm, apparently our version of wordpress doesn’t like code. I’ve uploaded it though. Take a look:

Sites For PHP Devs

Jonathan at DivisionByZero wrote up a nice article about some sites & strategies PHP devs should know about.  Especially those new to PHP development.


I especially agree with the PHP Manual.  PHP is highly community-driven, and the manual shows that.  Almost any function you search for in the manual, you’ll see a ton of community comments relating uses, caveats, etc.  I’ve been working with PHP for many years and I still hit the manual probably twice per week.


SQLite is a small mobile database engine…not mobile as in cellular; mobile as in you can take the database file and copy/move it to any other box with sqlite libraries and use it.  The database file can (and should) reside within the same directory structure as the application using it, unlike most database engines where all database files reside in the database server directory structure. This makes your entire application easily transferrable and installable (no need for database setup). Of course, it’s nowhere near as powerful as most database engines but for small applications or dynamic configurations, this kind of database works great.

Here’s a nice article and short tutorial on using PDO and SQLite: