Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

apache segfaults when we have register_globals turned on with php 5.3. I know we should not do that, and we have it off now, but some of our very old code needs it. Anyone have any hints on what to try/look at to solve this?


share|improve this question
up vote 4 down vote accepted

the patchwork approach
You can include some code in the very beginning of the very old script you can use one of the well known register_global compatibility code you can find googling.

An example may be:

// ################# :: Register Globals Compatibility :: #################
$globals_test = @ini_get('register_globals');
if ( isset($globals_test) && empty($globals_test) ) {
// These still need some work :: Cookie|Server|Env are ok now.
if ( !empty($HTTP_GET_VARS) )  { extract($HTTP_GET_VARS, EXTR_SKIP);  }
if ( !empty($HTTP_POST_VARS) ) { extract($HTTP_POST_VARS, EXTR_OVERWRITE); }
define('_GLOBALS', FALSE);
} else {
    define('_GLOBALS', TRUE);

The autopatchwork approach

You can add:

php_value   auto_prepend_file  "/path/to/file/with_the_above_code"

to your .htaccess or VirutualHosts section in order to automagically do the job without the need of touch any existing script.

The judicious approach
The best thing of course would be rewrite the old code, as register_globals is a well known evil.

share|improve this answer
thanks for this. We set it in the .htaccess file for the dir where the old code was, it was luckily contained in one dir. This doesn't seem to crash php, so it is a weird combination of certain code + the setting I'm guessing. – datadevil Aug 28 '09 at 10:02
I accepted it, but in our case we used this in the .htaccess: php_value register_globals on – datadevil Sep 15 '09 at 8:56

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.