cmgmyr Posted April 6, 2007 Share Posted April 6, 2007 Ok here is what I have right now: <?php $phpver = phpversion(); if ($phpver < '4.1.0') { $_GET = $HTTP_GET_VARS; $_POST = $HTTP_POST_VARS; $_SERVER = $HTTP_SERVER_VARS; } if ($phpver >= '4.0.4pl1' && strstr($_SERVER["HTTP_USER_AGENT"],'compatible')) { if (extension_loaded('zlib')) { ob_end_clean(); ob_start('ob_gzhandler'); } } else if ($phpver > '4.0') { if (strstr($HTTP_SERVER_VARS['HTTP_ACCEPT_ENCODING'], 'gzip')) { if (extension_loaded('zlib')) { $do_gzip_compress = TRUE; ob_start(array('ob_gzhandler',5)); ob_implicit_flush(0); } } } $phpver = explode(".", $phpver); $phpver = "$phpver[0]$phpver[1]"; if ($phpver >= 41) { $PHP_SELF = $_SERVER['PHP_SELF']; } if (!ini_get("register_globals")) { import_request_variables('GPC'); } ?> Right now I have a client with php 5.1.6 and currently this script makes it freeze up. How can I make this compatable with PHP 5? Thanks, -Chris Quote Link to comment https://forums.phpfreaks.com/topic/45909-config-file-php5-compatability-issue/ Share on other sites More sharing options...
cmgmyr Posted April 6, 2007 Author Share Posted April 6, 2007 *bump* anyone? Quote Link to comment https://forums.phpfreaks.com/topic/45909-config-file-php5-compatability-issue/#findComment-223135 Share on other sites More sharing options...
kenrbnsn Posted April 6, 2007 Share Posted April 6, 2007 You have <?php } else if ($phpver > '4.0') { if (strstr($HTTP_SERVER_VARS['HTTP_ACCEPT_ENCODING'], 'gzip')) { ?> Shouldn't that be <?php } else if ($phpver > '4.0') { if (strstr($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip')) { ?> Ken Quote Link to comment https://forums.phpfreaks.com/topic/45909-config-file-php5-compatability-issue/#findComment-223152 Share on other sites More sharing options...
wildteen88 Posted April 7, 2007 Share Posted April 7, 2007 You are using the older style superglobals. The older style superglobas was dropped with newer shorter superglobals when PHP4.2 was released. When PHP5 was release the devlopers dropped support for the older style superglobals and thus the setting regsiter_long_arrays was introduced and is disabled by default. You may enable this setting in the php.ini (if you can) or by using the ini_set function in your script. However it would be better if you updated your code to use the newer superglobals. YOu'd do this by changing $HTTP_*_VARS to $_* The * masks a word, example POST, GET, SERVER, SESSSION: $HTTP_GET_VARS should be $_GET $HTTP_POST_VARS should be $_POST $HTTP_COOKIE_VARS should be $_COOKIE $HTTP_SESSION_VARS shold be $_SESSION $HTTP_SERVER_VARS should be $_SERVER Quote Link to comment https://forums.phpfreaks.com/topic/45909-config-file-php5-compatability-issue/#findComment-223508 Share on other sites More sharing options...
cmgmyr Posted April 7, 2007 Author Share Posted April 7, 2007 Hey guys, thanks for the help. What I did is just at another statement for php5 ... to do nothing. When I uploaded it everything worked great. Here it is: <?php $phpver = phpversion(); if ($phpver < '4.1.0') { $_GET = $HTTP_GET_VARS; $_POST = $HTTP_POST_VARS; $_SERVER = $HTTP_SERVER_VARS; } if($phpver > '5.0'){ //Do nothing } else if ($phpver >= '4.0.4pl1' && strstr($_SERVER["HTTP_USER_AGENT"],'compatible')) { if (extension_loaded('zlib')) { ob_end_clean(); ob_start('ob_gzhandler'); } } else if ($phpver > '4.0') { if (strstr($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip')) { if (extension_loaded('zlib')) { $do_gzip_compress = TRUE; ob_start(array('ob_gzhandler',5)); ob_implicit_flush(0); } } } $phpver = explode(".", $phpver); $phpver = "$phpver[0]$phpver[1]"; if ($phpver >= 41) { $PHP_SELF = $_SERVER['PHP_SELF']; } if (!ini_get("register_globals")) { import_request_variables('GPC'); } ?> Is this right? (it works ) Quote Link to comment https://forums.phpfreaks.com/topic/45909-config-file-php5-compatability-issue/#findComment-223555 Share on other sites More sharing options...
wildteen88 Posted April 7, 2007 Share Posted April 7, 2007 I'd leave the following out: if($phpver > '5.0'){ //Do nothing } If you're not going to do anything in that statement then leave it out. If you keep it in then your script will not enable output compression, which is what that code sets up. I'd change your code to this: <?php $phpver = phpversion(); if ($phpver < '4.1.0') { $_GET = $HTTP_GET_VARS; $_POST = $HTTP_POST_VARS; $_SERVER = $HTTP_SERVER_VARS; } if ($phpver >= '4.0.4pl1' && strstr($_SERVER["HTTP_USER_AGENT"], 'compatible')) { if (extension_loaded('zlib')) { ob_end_clean(); ob_start('ob_gzhandler'); } } else if ($phpver > '4.0') { if (strstr($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip')) { if (extension_loaded('zlib') { $do_gzip_compress = TRUE; ob_start(array('ob_gzhandler',5)); ob_implicit_flush(0); } } } if ($phpver >= '4.1') { $PHP_SELF = $_SERVER['PHP_SELF']; } if (!ini_get("register_globals")) { import_request_variables('GPC'); } ?> Now that code will work for PHP4 and PHP5 Quote Link to comment https://forums.phpfreaks.com/topic/45909-config-file-php5-compatability-issue/#findComment-223615 Share on other sites More sharing options...
cmgmyr Posted April 7, 2007 Author Share Posted April 7, 2007 I had it out before and that's what froze it up Quote Link to comment https://forums.phpfreaks.com/topic/45909-config-file-php5-compatability-issue/#findComment-223617 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.