Jud Dagnall Photography Blog

Photography, technology and occasional rants!

The origin of PHP’s “global” keyword

Posted on December 17th, 2004 in by jud || No Comment

At lunch earlier this week, [Rasmus](http://lerdorf.com/bio.php) was telling a few of us a story that led to PHP’s *global* keyword.
As a college student, he got a work-study program assignment at a telco. When he showed up for work, they suggested that he spend his time reorganizing a massive rat’s nest of cables into a patch panel. He balked at this, and instead countered that they should give him some real code to work with. Evidently, this caused consternation and confusion on the part of management, leading to a flurry of activity and meetings as they tried to decide what to do with this cheeky “intern”: send him back , or give him something real to work on. Finally, he was given a real problem: discover why the switching system running on their proprietary OS was mysteriously and intermittently crashing. Rasmus went to work, taking over a hallway and walkpapering the walls and floor with highlighted printouts as he spent the next several weeks searching for the answer (think *A Beautiful Mind* :) ). Eventually, he found the source of the problem: a local variable that was overriding a global one. Later, when he was designing PHP, he wanted to be sure to eliminate this particular headache, hence PHP’s *global* keyword!

Leave a Reply

Your email address will not be published. Required fields are marked *