<?php
class MyClass
{
private $v;
function __construct($x) {
$this->v = $x;
}
public function getValue() {
return $this->v;
}
}
$one = new MyClass("I'm tough!");
echo "The one: " . $one->getValue() . "\n";
$i = 0;
foreach(array("one","two","three") as $h) { $$h = new MyClass("Says who? " . ++$i);
}
echo "The one: " . $one->getValue() . "\n";
echo $two->getValue() . "\n";
echo $three->getValue() . "\n";
?>
PD9waHAKCmNsYXNzIE15Q2xhc3MKewogICAgcHJpdmF0ZSAkdjsKICAgIGZ1bmN0aW9uIF9fY29uc3RydWN0KCR4KSB7CiAgICAgICAgJHRoaXMtPnYgPSAkeDsKICAgIH0KICAgIHB1YmxpYyBmdW5jdGlvbiBnZXRWYWx1ZSgpIHsKICAgICAgICByZXR1cm4gJHRoaXMtPnY7CiAgICB9Cn0KCiRvbmUgPSBuZXcgTXlDbGFzcygiSSdtIHRvdWdoISIpOwoKZWNobyAiVGhlIG9uZTogIiAuICRvbmUtPmdldFZhbHVlKCkgLiAiXG4iOwoKJGkgPSAwOwpmb3JlYWNoKGFycmF5KCJvbmUiLCJ0d28iLCJ0aHJlZSIpIGFzICRoKSB7CiAgICQkaCA9IG5ldyBNeUNsYXNzKCJTYXlzIHdobz8gIiAuICsrJGkpOwp9CgplY2hvICJUaGUgb25lOiAiIC4gJG9uZS0+Z2V0VmFsdWUoKSAuICJcbiI7CgplY2hvICR0d28tPmdldFZhbHVlKCkgLiAiXG4iOwplY2hvICR0aHJlZS0+Z2V0VmFsdWUoKSAuICJcbiI7Cgo/Pg==