Turn on register_globals from command line

Posted on 2011-10-11
Last Modified: 2012-05-12
I run an old PHP script from a command line like this:

php -d memory_limit=64M /my/script

Open in new window

How can I turn on register_globals for that?
Question by:hankknight
    LVL 42

    Accepted Solution

    use the -c option to specify a php.ini file you want to use and enable it in there
    LVL 82

    Assisted Solution

    by:Dave Baldwin
    This says that you can't, it must be done in 'php.ini' or '.htaccess'.  "register_globals" is going away soon so if you need to keep that script, you may have to modify it to use it on new versions after PHP 5.3.
    LVL 34

    Assisted Solution

    I second what Dave is saying. register_globals is going away for a good reason. It's always been a very large security risk, and if you're coming across scripts that depend on register_globals, it's in your best interests to spend the time to update them so you can turn it off for good.

    Having it enabled puts all of your scripts at risk, even those that have been coded in a generally-secure way because having it enabled gives hackers the ability to set or override any variable they want in your script. That ability can be used in all sorts of ways to deface sites or even gain access to the value of your database connection credentials.

    Just keep it off and fix the scripts - it's usually quicker to fix the scripts than you might think.
    LVL 1

    Assisted Solution

    There's no point of using such an old script, if it still uses

    Open in new window


    Open in new window

    allows your script to be hacked easier, as hackers can simply send a variable through another method (

    Open in new window


    Open in new window

    ) and bypass your script.

    Search around the script, and replace any place where the script relies on

    Open in new window

    to use more secure methods. Having old scripts on your server is a security risk.
    LVL 107

    Assisted Solution

    by:Ray Paseur
    See this article:

    To simulate part of the effect of register globals you can extract() the superglobal arrays in the order given by variables_order.  But I'm firmly in the camp with the other experts here - fix the defective code that depends on register globals and do it sooner rather than later!

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    What Should I Do With This Threat Intelligence?

    Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

    Both Easy and Powerful How easy is PHP? (  Very easy.  It has been described as "a programming language even my grandmother can use." How powerful is PHP?  http://en.wikiped…
    Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
    The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
    This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

    794 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now