fork(1) download
  1. <?php
  2.  
  3. class MyClass
  4. {
  5. private $v;
  6. function __construct($x) {
  7. $this->v = $x;
  8. }
  9. public function getValue() {
  10. return $this->v;
  11. }
  12. }
  13.  
  14. $one = new MyClass("I'm tough!");
  15.  
  16. echo "The one: " . $one->getValue() . "\n";
  17.  
  18. $i = 0;
  19. foreach(array("one","two","three") as $h) {
  20. $$h = new MyClass("Says who? " . ++$i);
  21. }
  22.  
  23. echo "The one: " . $one->getValue() . "\n";
  24.  
  25. echo $two->getValue() . "\n";
  26. echo $three->getValue() . "\n";
  27.  
  28. ?>
Success #stdin #stdout 0.02s 13112KB
stdin
Standard input is empty
stdout
The one: I'm tough!
The one: Says who? 1
Says who? 2
Says who? 3