Created
October 24, 2011 18:21
-
-
Save bitops/1309707 to your computer and use it in GitHub Desktop.
Not doing PHP correctly?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class Dummy { | |
public $foos = array(); | |
public function & getFoos() { | |
return $this->foos; | |
} | |
public function addFoo($foo) { | |
array_push($this->foos, $foo); | |
} | |
} | |
$d = new Dummy(); | |
var_dump($d); | |
$d->addFoo("a"); | |
$d->addFoo("b"); | |
$d->addFoo("c"); | |
var_dump($d); //has 3 | |
$foos = &$d->getFoos(); //mystery solved | |
unset($foos[1]); | |
var_dump($d); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment