3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php class Input {                                       // Reading input file from codeabbey (in this case from 'std' file on my pc)     public $first_line = null;                      // I am using this class in every problem on the site so its more complicated     public $data = null;                            // than required for this problem     public function __construct($input) {           // Puting 1st line (helper) in $firstline and rest of array in $data         $input = file_get_contents($input);         $input = explode("\n", $input);         $this->first_line = $input[0];         array_shift($input);         $this->data = $input;     }     public function toIntegers() {                  // Convert strings from array in integers         $data = $this->data;                        // Didn't use this for this problem         foreach ($data as $key=>$value) {             $data[$key] = (int)$value;         }         $this->data = $data;     } } class Fibonacci {                                   // Creating Fibonacci array and counting steps for problem     private $data;     public $hits = array();     public function __construct($input) {           // Loading input array in class         $this->data = $input;     }     public function createFibonacci($number) {      // Function: Creating fibonacci array until it reaches certain number         $fibonacci = array(0,1);                    // Argument: Limit number up to which array is created         $a = true;                                  // Return:   Fibonacci array         $count = 0;         while ($a) {             $length = count($fibonacci);             $count++;             $fibonacci[] = bcadd($fibonacci[$length-1], $fibonacci[$length-2]);             if ($fibonacci[$length-1] == $number) {                 echo "found match as $count for number $number<br>";                 $this->hits[] = $count;                 $a = false;             }             if ($count > 2000) {                 $a = false;                 echo 'timed! <br>';             }         }     }     public function countIndex() {                  // Function: counting index at which given number occured         foreach ($this->data as $key => $value) {   // Arguments: --             $this->createFibonacci($value);         // Return: index number for each number in array         }     } } $input = new Input('std'); $data = $input->data; $fibonacci = new Fibonacci($data); $fibonacci->countIndex();
Output for 5.4.0 - 5.4.31
Parse error: syntax error, unexpected ' ' (T_STRING), expecting function (T_FUNCTION) in /in/mYDjP on line 3
Process exited with code 255.
Output for 5.1.0 - 5.3.28
Parse error: syntax error, unexpected T_STRING, expecting T_FUNCTION in /in/mYDjP on line 3
Process exited with code 255.
Output for 5.0.0 - 5.0.5
Parse error: parse error, unexpected T_STRING, expecting T_FUNCTION in /in/mYDjP on line 3
Process exited with code 255.
Output for 4.4.2 - 4.4.9
Parse error: syntax error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/mYDjP on line 3
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.4.1
Parse error: parse error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/mYDjP on line 3
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error, expecting `T_OLD_FUNCTION' or `T_FUNCTION' or `T_VAR' or `'}'' in /in/mYDjP on line 3
Process exited with code 255.