$_GET by reference

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
Benjamin
Site Administrator
Posts: 6935
Joined: Sun May 19, 2002 10:24 pm

$_GET by reference

Post by Benjamin »

What am I missing here? I would have thought this would work fine:

Code: Select all

<?php
$_GET = array('foo' => 'foo', 'bar' => 'bar');

class referenceTest {
    private $get = array();

    public function __construct() {
        $this->get &= $_GET;
        unset($this->get['foo']);
    }
}

$n = new referenceTest();

echo '<pre>' . print_r($_GET, true) . '</pre>';
Outputs:
Array
(
[foo] => foo
[bar] => bar
)
User avatar
Benjamin
Site Administrator
Posts: 6935
Joined: Sun May 19, 2002 10:24 pm

Re: $_GET by reference

Post by Benjamin »

My bad, &= should be =&.
Post Reply