PHP

Disabling PHP's register_globals in userland

Tagged:
So you have a large PHP deployment that is (still? - this is 2008!) using register_globals. How do you test individual pieces of the site without being able to change the ini variable via .htaccess? Try this code out:
<?php
if (ini_get('register_globals'))
{
        $__sgs = array('_ENV', '_GET', '_POST', '_COOKIE', '_SERVER');
        foreach ($__sgs as $__sg)
        {
                $__k = array_keys(${$__sg});
                foreach($__k as $__v)
                {
                        if (isset($$__v) && ${$__sg}[$__v] === $$__v)
                        {
                                unset($$__v);
                        } // end if superglobal var = local var
                } // end foreach superglobal key
        } // end foreach superglobal
} // end if register_globals
?>

Ruby-on-Rails is not a PHP killer

Tagged:  •  

My suspicions about RoR appear to be vindicated; at least by one person anyway.

I've tried to read some examples and howtos about Ruby and Ruby-on-Rails. The language seems very elegant, but I always heard that it's slow and suspected that it's ability to do lots of different things was limited. I've picked up some python recently and found that using objects for everything (mostly) works out very well. In PHP 5, OOP is very well supported (with some caveats) and if you have a firm grasp on OOP, PHP can even begin to look like Ruby (see: fluent interface).


Syndicate content