3v4l.org

run code in 300+ PHP versions simultaneously
<?php class ErrorPrinter { /* ARRAY KEYS */ const KEY_NUMBER_OF_ERRORS = "number_of_errors"; const KEY_ERRORS = "errors"; /* ERROR CODES */ const ERROR_MISSING_PARAM = "10000"; //parameter missing from http post private $response = array(); private $errors = array(); private $number_of_errors = 0; function addError($error, $variable){ $this->errors[$variable] = $error; $this->number_of_errors = count($this->errors); } function printToJson(){ $response[$this->KEY_ERRORS] = $this->errors; $response[$this->KEY_NUMBER_OF_ERRORS] = $this->number_of_errors; return json_encode($this->response); } function getNumberOfErrors(){ return $this->number_of_errors; } } $printer = new ErrorPrinter; $printer->addError(ErrorPrinter::ERROR_MISSING_PARAM, 'name'); echo $printer->printToJson();
Output for git.master, git.master_jit, rfc.property-hooks
Warning: Undefined property: ErrorPrinter::$KEY_ERRORS in /in/Pli7O on line 22 Warning: Undefined property: ErrorPrinter::$KEY_NUMBER_OF_ERRORS in /in/Pli7O on line 23 []

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
43.16 ms | 401 KiB | 8 Q