3v4l.org

run code in 300+ PHP versions simultaneously
<?php /* String to print for an error where a parameter is missing from the post */ const ERROR_MISSING_PARAM = "10000"; $errors = array(); $number_of_errors = 0; function addError($error, $variable){ $errors[$variable] = $error; $number_of_errors = count($errors); } function printToJson(){ return json_encode($this->errors); } addError(ERROR_MISSING_PARAM, 'name'); echo $number_of_errors . "\r\n"; echo printToJson();

preferences:
60.85 ms | 402 KiB | 5 Q