3v4l.org

run code in 300+ PHP versions simultaneously
<?php // class MyException extends Exception // { // public static $myErrLvls = array( // 1 => "E_ERROR", // 2 => "E_WARNING", // 4 => "E_PARSE", // 8 => "E_NOTICE", // 16 => "E_CORE_ERROR", // 32 => "E_CORE_WARNING", // 64 => "E_COMPILE_ERROR", // 128 => "E_COMPILE_WARNING", // 256 => "E_USER_ERROR", // 512 => "E_USER_WARNING", // 1024 => "E_USER_NOTICE", // 2048 => "E_STRICT", // 4096 => "E_RECOVERABLE_ERROR", // 8192 => "E_DEPRECATED", // 16384 => "E_USER_DEPRECATED", // 32767 => "E_ALL", // ); // private $myMsg; // private $myCode; // public function __construct($message, $code = 0, Exception $previous = null) { // $this->myMsg = $message; // $this->myCode = $code; // parent::__construct($message, $code, $previous); // } // public function __toString() { // return __CLASS__ . ": [{$this->code}]: {$this->message}\n"; // } // public function getErrorArray() { // return array( // 'errLvl' => self::$myErrLvls[$this->myCode], // 'errNo' => $this->myCode, // 'errMsg' => $this->myMsg, // ); // } // } class Odometer { public function __construct(array $values, $max_places = 0){ $this->values = array_values($values); $this->max_places = $max_places; reset($values); $this->register[0] = key($values); end($values); $this->limit = key($values); } public function iterate($force = false){ $rollback = $this->register; $this->register[0]++; var_dump($regsiter); for($i = 0; $i < count($this->register); $i++){ if($this->register[$i] > $this->limit){ $this->register[$i] = 0; if(isset($this->register[$i+1])){ $this->register[$i+1]++; } else { if($this->max_places && count($this->register)+1 > $this->max_places && !$force){ $this->register = $rollback; return; } $this->register[$i+1] = 0; } } } } public function readMeter(){ for($i = 0; $i < count($this->register); $i++){ $meter[$i] = $this->values[$this->register[$i]]; } return $meter; } public function printMeter(){ // $this->setMeter(); return '[' . implode('][', array_reverse($this->readMeter())) . ']' . "\n"; } } $output = array(); $func = 'sqlite_open'; $empty = array( // -1 for no argument "''" => '', "\"\"" => "", "\"\"" => "\n", "' '" => ' ', "0" => 0, "0.0" => 0.0, "NULL" => NULL, "\\0" => "\0", "array()" => array(), "false" => false, "new stdClass()" => new stdClass(), ); // $refl = new ReflectionFunction($func); // $totalNumOfArgs = $refl->getNumberOfParameters(); $o = new Odometer($empty, 2); for($i = 0; $i < 50; $i++){ $o->iterate(); // var_dump($o->readMeter()); } // for($i = -1; $i < count($empty); $i++){ // // $args = isset($empty[$i]) ? array($empty[$i]) : array(); // if(isset($empty[$i])){ // if($i == 0){ $args = array($o->readMeter()); } // else if($i > 0){ $o->iterate(); $args = array($o->readMeter()); } // else { $args = array(); } // } // // try { // // $result = call_user_func_array('sqlite_open', $args); // // $output[$func][$i] = array( // // 'args' => $args, // // 'result' => $result, // // 'result_type' => gettype($result), // // ); // // } catch (MyException $e){ // // $output[$func][$i]['error'] = array( // // $e->getErrorArray(), // // ); // // } // var_dump($args); // }

preferences:
58.38 ms | 402 KiB | 5 Q