3v4l.org

run code in 300+ PHP versions simultaneously
<?php function isString($value) { return is_string($value); } $vBase = [ 'date' => function($value) { return (bool)preg_match('/^\d{2}\.\d{2}\.\d{4}$/', $value); }, 'string' => isString, ]; $dateVal[] = date('d.m.Y'); $dateVal[] = date('Y-m-d'); foreach ($dateVal as $date) { var_dump( [ 'value' => $date, 'isValidFormat' => $vBase['date']($date), ] ); } var_dump($vBase['string'](1));
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 16, Position 2 = 27
Branch analysis from position: 16
2 jumps found. (Code = 78) Position 1 = 17, Position 2 = 27
Branch analysis from position: 17
1 jumps found. (Code = 42) Position 1 = 16
Branch analysis from position: 16
Branch analysis from position: 27
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 27
filename:       /in/EGf5r
function name:  (null)
number of ops:  36
compiled vars:  !0 = $vBase, !1 = $dateVal, !2 = $date
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    8     0  E >   DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FEGf5r%3A8%240'
   10     1        INIT_ARRAY                                       ~4      ~3, 'date'
   11     2        FETCH_CONSTANT                                   ~5      'isString'
          3        ADD_ARRAY_ELEMENT                                ~4      ~5, 'string'
    7     4        ASSIGN                                                   !0, ~4
   14     5        INIT_FCALL                                               'date'
          6        SEND_VAL                                                 'd.m.Y'
          7        DO_ICALL                                         $8      
          8        ASSIGN_DIM                                               !1
          9        OP_DATA                                                  $8
   15    10        INIT_FCALL                                               'date'
         11        SEND_VAL                                                 'Y-m-d'
         12        DO_ICALL                                         $10     
         13        ASSIGN_DIM                                               !1
         14        OP_DATA                                                  $10
   17    15      > FE_RESET_R                                       $11     !1, ->27
         16    > > FE_FETCH_R                                               $11, !2, ->27
   18    17    >   INIT_FCALL                                               'var_dump'
   20    18        INIT_ARRAY                                       ~12     !2, 'value'
   21    19        FETCH_DIM_R                                      ~13     !0, 'date'
         20        INIT_DYNAMIC_CALL                                        ~13
         21        SEND_VAR_EX                                              !2
         22        DO_FCALL                                      0  $14     
         23        ADD_ARRAY_ELEMENT                                ~12     $14, 'isValidFormat'
         24        SEND_VAL                                                 ~12
         25        DO_ICALL                                                 
   17    26      > JMP                                                      ->16
         27    >   FE_FREE                                                  $11
   26    28        INIT_FCALL                                               'var_dump'
         29        FETCH_DIM_R                                      ~16     !0, 'string'
         30        INIT_DYNAMIC_CALL                                        ~16
         31        SEND_VAL_EX                                              1
         32        DO_FCALL                                      0  $17     
         33        SEND_VAR                                                 $17
         34        DO_ICALL                                                 
         35      > RETURN                                                   1

Function isstring:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/EGf5r
function name:  isString
number of ops:  4
compiled vars:  !0 = $value
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
    4     1        TYPE_CHECK                                   64  ~1      !0
          2      > RETURN                                                   ~1
    5     3*     > RETURN                                                   null

End of function isstring

Function %00%7Bclosure%7D%2Fin%2FEGf5r%3A8%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/EGf5r
function name:  {closure}
number of ops:  8
compiled vars:  !0 = $value
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    8     0  E >   RECV                                             !0      
    9     1        INIT_FCALL                                               'preg_match'
          2        SEND_VAL                                                 '%2F%5E%5Cd%7B2%7D%5C.%5Cd%7B2%7D%5C.%5Cd%7B4%7D%24%2F'
          3        SEND_VAR                                                 !0
          4        DO_ICALL                                         $1      
          5        BOOL                                             ~2      $1
          6      > RETURN                                                   ~2
   10     7*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FEGf5r%3A8%240

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
156.12 ms | 1392 KiB | 19 Q