3v4l.org

run code in 300+ PHP versions simultaneously
<?php function array_is_numerical($unsafeArray) { foreach($unsafeArray as $entry) { if (!is_numeric($entry)) { return false; } } return true; } function foo($numeric_OR_array) { if (is_array($numeric_OR_array) and array_is_numeric($numeric_OR_array)) { return "True"; } else { return "False"; } } $testArray = array(1,2,3,4,5); $testArray2 = array(1,2,3,'vier',5); $testNumber = 1; echo '(' . join(', ', $testArray) . ')'; echo ' -- '; echo(foo($testArray)); echo ' -- '; echo(foo($testArray2)); echo ' -- '; echo(foo($testNumber));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/iRtDc
function name:  (null)
number of ops:  26
compiled vars:  !0 = $testArray, !1 = $testArray2, !2 = $testNumber
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   23     0  E >   ASSIGN                                                   !0, <array>
   24     1        ASSIGN                                                   !1, <array>
   25     2        ASSIGN                                                   !2, 1
   27     3        INIT_FCALL                                               'join'
          4        SEND_VAL                                                 '%2C+'
          5        SEND_VAR                                                 !0
          6        DO_ICALL                                         $6      
          7        CONCAT                                           ~7      '%28', $6
          8        CONCAT                                           ~8      ~7, '%29'
          9        ECHO                                                     ~8
   28    10        ECHO                                                     '+--+'
   29    11        INIT_FCALL                                               'foo'
         12        SEND_VAR                                                 !0
         13        DO_FCALL                                      0  $9      
         14        ECHO                                                     $9
   30    15        ECHO                                                     '+--+'
   31    16        INIT_FCALL                                               'foo'
         17        SEND_VAR                                                 !1
         18        DO_FCALL                                      0  $10     
         19        ECHO                                                     $10
   32    20        ECHO                                                     '+--+'
   33    21        INIT_FCALL                                               'foo'
         22        SEND_VAR                                                 !2
         23        DO_FCALL                                      0  $11     
         24        ECHO                                                     $11
         25      > RETURN                                                   1

Function array_is_numerical:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 2, Position 2 = 11
Branch analysis from position: 2
2 jumps found. (Code = 78) Position 1 = 3, Position 2 = 11
Branch analysis from position: 3
2 jumps found. (Code = 43) Position 1 = 8, Position 2 = 10
Branch analysis from position: 8
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 10
1 jumps found. (Code = 42) Position 1 = 2
Branch analysis from position: 2
Branch analysis from position: 11
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 11
filename:       /in/iRtDc
function name:  array_is_numerical
number of ops:  14
compiled vars:  !0 = $unsafeArray, !1 = $entry
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
    5     1      > FE_RESET_R                                       $2      !0, ->11
          2    > > FE_FETCH_R                                               $2, !1, ->11
    6     3    >   INIT_FCALL                                               'is_numeric'
          4        SEND_VAR                                                 !1
          5        DO_ICALL                                         $3      
          6        BOOL_NOT                                         ~4      $3
          7      > JMPZ                                                     ~4, ->10
    7     8    >   FE_FREE                                                  $2
          9      > RETURN                                                   <false>
    5    10    > > JMP                                                      ->2
         11    >   FE_FREE                                                  $2
   10    12      > RETURN                                                   <true>
   11    13*     > RETURN                                                   null

End of function array_is_numerical

Function foo:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 46) Position 1 = 3, Position 2 = 7
Branch analysis from position: 3
2 jumps found. (Code = 43) Position 1 = 8, Position 2 = 10
Branch analysis from position: 8
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 10
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 7
filename:       /in/iRtDc
function name:  foo
number of ops:  12
compiled vars:  !0 = $numeric_OR_array
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   13     0  E >   RECV                                             !0      
   14     1        TYPE_CHECK                                  128  ~1      !0
          2      > JMPZ_EX                                          ~1      ~1, ->7
          3    >   INIT_FCALL_BY_NAME                                       'array_is_numeric'
          4        SEND_VAR_EX                                              !0
          5        DO_FCALL                                      0  $2      
          6        BOOL                                             ~1      $2
          7    > > JMPZ                                                     ~1, ->10
   16     8    > > RETURN                                                   'True'
          9*       JMP                                                      ->11
   18    10    > > RETURN                                                   'False'
   20    11*     > RETURN                                                   null

End of function foo

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
146.61 ms | 1403 KiB | 20 Q