3v4l.org

run code in 300+ PHP versions simultaneously
<?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();
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/1u85n
function name:  (null)
number of ops:  14
compiled vars:  !0 = $printer
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   24     0  E >   NEW                                              $1      'ErrorPrinter'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $1
   25     3        INIT_METHOD_CALL                                         !0, 'addError'
          4        SEND_VAL_EX                                              '10000'
          5        SEND_VAL_EX                                              'name'
          6        DO_FCALL                                      0          
   26     7        FETCH_OBJ_R                                      ~5      !0, 'getNumberOfErrors'
          8        CONCAT                                           ~6      ~5, '%0D%0A'
          9        ECHO                                                     ~6
   27    10        INIT_METHOD_CALL                                         !0, 'printToJson'
         11        DO_FCALL                                      0  $7      
         12        ECHO                                                     $7
         13      > RETURN                                                   1

Class ErrorPrinter:
Function adderror:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/1u85n
function name:  addError
number of ops:  10
compiled vars:  !0 = $error, !1 = $variable
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   10     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   11     2        FETCH_OBJ_W                                      $2      'errors'
          3        ASSIGN_DIM                                               $2, !1
          4        OP_DATA                                                  !0
   12     5        FETCH_OBJ_R                                      ~5      'errors'
          6        COUNT                                            ~6      ~5
          7        ASSIGN_OBJ                                               'number_of_errors'
          8        OP_DATA                                                  ~6
   13     9      > RETURN                                                   null

End of function adderror

Function printtojson:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/1u85n
function name:  printToJson
number of ops:  6
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   16     0  E >   INIT_FCALL                                               'json_encode'
          1        FETCH_OBJ_R                                      ~0      'errors'
          2        SEND_VAL                                                 ~0
          3        DO_ICALL                                         $1      
          4      > RETURN                                                   $1
   17     5*     > RETURN                                                   null

End of function printtojson

Function getnumberoferrors:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/1u85n
function name:  getNumberOfErrors
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   20     0  E >   FETCH_OBJ_R                                      ~0      'number_of_errors'
          1      > RETURN                                                   ~0
   21     2*     > RETURN                                                   null

End of function getnumberoferrors

End of class ErrorPrinter.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
146.74 ms | 1400 KiB | 15 Q