3v4l.org

run code in 300+ PHP versions simultaneously
<?php class ErrorPrinter { /* ARRAY KEYS */ private $KEY_NUMBER_OF_ERRORS = "number_of_errors"; //key for number of errors present private $KEY_ERRORS = "errors"; //key for the array of 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();
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/cbKbn
function name:  (null)
number of ops:  11
compiled vars:  !0 = $printer
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   32     0  E >   NEW                                              $1      'ErrorPrinter'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $1
   33     3        INIT_METHOD_CALL                                         !0, 'addError'
          4        SEND_VAL_EX                                              '10000'
          5        SEND_VAL_EX                                              'name'
          6        DO_FCALL                                      0          
   34     7        INIT_METHOD_CALL                                         !0, 'printToJson'
          8        DO_FCALL                                      0  $5      
          9        ECHO                                                     $5
         10      > RETURN                                                   1

Class ErrorPrinter:
Function adderror:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/cbKbn
function name:  addError
number of ops:  10
compiled vars:  !0 = $error, !1 = $variable
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   16     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   17     2        FETCH_OBJ_W                                      $2      'errors'
          3        ASSIGN_DIM                                               $2, !1
          4        OP_DATA                                                  !0
   18     5        FETCH_OBJ_R                                      ~5      'errors'
          6        COUNT                                            ~6      ~5
          7        ASSIGN_OBJ                                               'number_of_errors'
          8        OP_DATA                                                  ~6
   19     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/cbKbn
function name:  printToJson
number of ops:  14
compiled vars:  !0 = $response
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   22     0  E >   FETCH_OBJ_R                                      ~1      'KEY_ERRORS'
          1        FETCH_OBJ_R                                      ~3      'errors'
          2        ASSIGN_DIM                                               !0, ~1
          3        OP_DATA                                                  ~3
   23     4        FETCH_OBJ_R                                      ~4      'KEY_NUMBER_OF_ERRORS'
          5        FETCH_OBJ_R                                      ~6      'number_of_errors'
          6        ASSIGN_DIM                                               !0, ~4
          7        OP_DATA                                                  ~6
   24     8        INIT_FCALL                                               'json_encode'
          9        FETCH_OBJ_R                                      ~7      'response'
         10        SEND_VAL                                                 ~7
         11        DO_ICALL                                         $8      
         12      > RETURN                                                   $8
   25    13*     > 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/cbKbn
function name:  getNumberOfErrors
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   28     0  E >   FETCH_OBJ_R                                      ~0      'number_of_errors'
          1      > RETURN                                                   ~0
   29     2*     > RETURN                                                   null

End of function getnumberoferrors

End of class ErrorPrinter.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
168.72 ms | 1400 KiB | 15 Q