fork(1) download
  1. <?php
  2.  
  3. $array = [];
  4.  
  5. class Test
  6. {
  7. private $testValue = "test";
  8.  
  9. public function getTestValue()
  10. {
  11. return $this->testValue;
  12. }
  13. }
  14.  
  15. for($i = 0; $i < 5; $i++) {
  16. $array[] = new Test; // или clone Test
  17. }
  18.  
  19. foreach($array as $value) {
  20. echo $value->getTestValue() . PHP_EOL;
  21. }
Success #stdin #stdout 0.05s 24188KB
stdin
Standard input is empty
stdout
test
test
test
test
test