Search code examples
php-5.5joomla3.4

Fatal error: Cannot re-assign auto-global variable _REQUEST in /var/www/data/system/address/index.php on line 34


Hi i got after a Update to PHP 5.5.9 a Problem with my PHP Code. Can some one help me ?

}

public function update($_REQUEST) {
    $form = this->createForm('', @$_REQUEST['aID']);
    //$form->showQuery = true;
    $form->saveExistingEntry();

    return '<h1 class="go">Gespeichert</h1>';
}

Solution

  • What this error is saying is that you are attempting to name a variable in the function $_REQUEST. That is a reserved variable name. You cannot create your own variable with that name. But, you say, I don't think I'm that!? Yes. By making a parameter of your function named $_REQUEST, you are saying: Within this function, I have a variable that I will name $_REQUEST. So, you are attempting to create a variable named $_REQUEST.

    So, the fix...

    public function update() {
    

    That avoids naming a variable $_REQUEST. But, how can you access $_REQUEST inside the function? It is an auto-global. It exists everywhere. Therefore, your attempt to access $_REQUEST['aID'] will work even though you didn't put $_REQUEST in the parameter.