3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php class ErrorPrinter { /* String to print for an error where a parameter is missing from the post */ const ERROR_MISSING_PARAM = "10000"; 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(){ return json_encode($this->errors); } function getNumberOfErrors(){ return $this->number_of_errors; } } $printer = new ErrorPrinter; $printer->addError(ErrorPrinter::ERROR_MISSING_PARAM, 'name'); echo $printer->getNumberOfErrors . "\r\n"; echo $printer->printToJson();
based on Bu5a7

Shows result from various feature-branches currently under review from the php developers. Contact me to have additional branches featured.

Output for Typed properties v2
Notice: Undefined property: ErrorPrinter::$getNumberOfErrors in /in/1u85n on line 26 {"name":"10000"}
Output for Array change keys
Notice: Undefined property: ErrorPrinter::$getNumberOfErrors in /in/1u85n on line 26 {"name":"10000"}
Output for Lexical anon
Notice: Undefined property: ErrorPrinter::$getNumberOfErrors in /in/1u85n on line 26 {"name":"10000"}

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