3v4l.org

run code in 300+ PHP versions simultaneously
<?php <?php interface Randomizer { public function randomize(); } class PHPRandRandomizer implements Randomizer { public function randomize() { return rand(1, 10); } } class LetterRandomizer implements Randomizer { private $letters = array('a','b','c','d','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'); public function randomize() { echo $this->letters[rand(1,24)]; } } class Matrix { private $randomizer; private $running = false; private $counter = 0; public function __construct(Randomizer $randomizer) { $this->randomizer = $randomizer; } public function start() { $this->running = true; $this->run(); } public function stop() { $this->running = false; } public function run() { while($this->running) { $this->counter++; // Alles in de console heel snel na elkaar uit echo'en om een matrix effect te creeƫren. echo $this->randomizer->randomize(); if ($this->counter > 50000000) { // De matrix stopt na een x aantal keren. $this->stop(); } } } } $matrix = new Matrix(new LetterRandomizer); // Hier gebruiken we een letter randomizer, maar je kan ook de PHPRandRandomizer gebruiken, met cijfertjes. $matrix->start();
Output for 5.3.0 - 5.3.27, 5.4.0 - 5.4.19, 5.5.0 - 5.5.3
Parse error: syntax error, unexpected '<' in /in/64rpL on line 2
Process exited with code 255.

preferences:
178.51 ms | 1395 KiB | 59 Q