0

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:

        require("includes/classloader_platform.php");
line 7->$classloader =& NEW classloader('0','30',$_GET,'1');
        $classloader->initialize($classloader);

line 154-> function __construct($cache=false,$cache_lifecycle=false,$_REQUEST,$template_parser=false) {
           ini_set("memory_limit","200M");
           //globalize _REQUEST
           $this->_REQUEST=$_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?

1
  • rename your local $_REQUEST in the constructor to some other things Commented Jul 17, 2012 at 17:47

1 Answer 1

4

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) {
    // ...
    $this->_REQUEST=$REQUEST;
    // ...
Sign up to request clarification or add additional context in comments.

7 Comments

That worked but now I'm getting "Fatal error: Call to undefined function apc_fetch()" from this: "$hits=apc_fetch("_STATS".$key);" Is apc_fetch() not supported anymore?
apc_fetch() is still definitely part of the APC extension. Is APC enabled?
Probably not. I looked in the "php.ini" file for ";extension=apc.so" but I couldn't find it. Is there a different way to do it?
No, that's the way to enable it, but you probably need to compile it first. I don't think it comes in the standard distribution.
@CharlesMurray Come to think of it, if you've installed PHP via your systems package manager (e.g., apt or yum), there might simply be a php-apc package you could install instead.
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.