3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php abstract class EmailInserter { protected $emails = array(); public static function printLinks($emails, $int = 1){ if($int > count($emails)){ // Fallback on max $int = count($emails); } $output = ''; while($int--){ $rand = rand(0, count($emails) - 1); $email = $emails[$rand]; unset($emails[$rand]); $emails = array_values($emails); $output .= '<a href="mailto:' . $email . '">' . $email . '</a>' . "\n"; } echo $output; } } class FooEmailInserter extends EmailInserter{ private static $locals = array( "SandieCapone", "KrystleKittinger", "AnnettaOno", "FridaFlagg", "ShirelyCacho", "MercyScarpa", "BurmaMask", "MatthewWarfel", "MyraCoad", "ReneePietz", ); private static $domains = array("gmail", "yahoo"); public static function print($int = 4, $print = true){ $emails = array(); foreach(self::$locals as $local){ foreach(self::$domains as $domain){ $emails[] = "$local@$domain.com"; } } if($print){ self::printLinks($emails, $int); } return $emails; } public function __construct($int = NULL){ $print = $int ? true : false; $this->emails = self::print($int, $print); } public function printLinks($int){ self::printLinks($this->emails, $int); } } $foo = new FooEmailInserter(); $foo->printLinks(10); FooEmailInserter::init();
based on s9Of2
Output for 7.0.0 - 7.0.2
Fatal error: Cannot make static method EmailInserter::printLinks() non static in class FooEmailInserter in /in/e1WTd on line 59
Process exited with code 255.
Output for 5.4.11 - 5.6.17
Parse error: syntax error, unexpected 'print' (T_PRINT), expecting identifier (T_STRING) in /in/e1WTd on line 40
Process exited with code 255.
Output for 5.3.21 - 5.3.29
Parse error: syntax error, unexpected T_PRINT, expecting T_STRING in /in/e1WTd on line 40
Process exited with code 255.