January 18th, 2007

tintype

Healthy Rebound

The upside of getting sick is my tendency to fight back by being extra healthy. I haven't smoked a cigarette since saturday, and have drank only one beer since then too. I've been going to kung fu class and riding my bicycle, so I almost feel fit. I think I can keep up this health binge for one more day, but once the weekend starts tomorrow evening, all bets are off.
tintype

PHP Scope

Working on a PHP script for someone tonight I banged my head on the most unusual problem. I was trying to access what I thought was a globally declared array from within a function. I kept getting the error Undefined variable: foo when trying to use the foo array. I tried passing the array into the function, and that worked, but seemed unnecessary.

It turns out that you need to declare global variables inside functions that want to use them. So by putting global foo; inside my function it could now access the globally declared array. I don't think I've ever come across this method for handling global variables before.