Charles Murray Charles Murray - 1 year ago 57
PHP Question

PHP5 with old PHP4 code

My friend wants me to tweak his website. But I'm getting the errors

Deprecated: Assigning the return value of new by reference is deprecated in C:\xampp\htdocs\toolmanager\toolmanager\index.php on line 7

Fatal error: Cannot re-assign auto-global variable _REQUEST in C:\xampp\htdocs\toolmanager\toolmanager\includes\classloader_platform.php on line 154

when I try to run the code on apache with PHP5. Here's the code:

line 7->$classloader =& NEW classloader('0','30',$_GET,'1');

line 154-> function __construct($cache=false,$cache_lifecycle=false,$_REQUEST,$template_parser=false) {
//globalize _REQUEST

I think it's because he wrote it by PHP4 standards so would it be better to switch apache to PHP4 or are there some simple fixes for these errors?


Do not revert to PHP 4. It is old and unsupported.

For "Deprecated: Assigning the return value of new by reference", just remove the &. It's redundant.

$classloader = NEW classloader(...);

For "Fatal error: Cannot re-assign auto-global variable", rename the function argument $_REQUEST to something else such as $REQUEST, then rename the subsequent occurrences of it within the function. You can't have a function argument with the same name as a superglobal.

function __construct($cache=false,$cache_lifecycle=false,$REQUEST,$template_parser=false) {
    // ...
    // ...