3v4l.org

run code in 300+ PHP versions simultaneously
<?php function add(float $a, float $b): float { return $a + $b; } var_dump(add("1", "1")); // float(2) var_dump(add("1", "1foo")); // PHP Notice: A non well formed numeric value encountered // float(2) var_dump((float) "foo"); // float(0) var_dump(floatval("foo")); // float(0) var_dump(add("1", "foo")); // PHP Fatal error: Uncaught TypeError: Argument 2 passed to add() must be of the type float, string given
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/4OQeZ
function name:  (null)
number of ops:  30
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   INIT_FCALL                                               'var_dump'
          1        INIT_FCALL                                               'add'
          2        SEND_VAL                                                 '1'
          3        SEND_VAL                                                 '1'
          4        DO_FCALL                                      0  $0      
          5        SEND_VAR                                                 $0
          6        DO_ICALL                                                 
    9     7        INIT_FCALL                                               'var_dump'
          8        INIT_FCALL                                               'add'
          9        SEND_VAL                                                 '1'
         10        SEND_VAL                                                 '1foo'
         11        DO_FCALL                                      0  $2      
         12        SEND_VAR                                                 $2
         13        DO_ICALL                                                 
   12    14        INIT_FCALL                                               'var_dump'
         15        CAST                                          5  ~4      'foo'
         16        SEND_VAL                                                 ~4
         17        DO_ICALL                                                 
   14    18        INIT_FCALL                                               'var_dump'
         19        CAST                                          5  ~6      'foo'
         20        SEND_VAL                                                 ~6
         21        DO_ICALL                                                 
   16    22        INIT_FCALL                                               'var_dump'
         23        INIT_FCALL                                               'add'
         24        SEND_VAL                                                 '1'
         25        SEND_VAL                                                 'foo'
         26        DO_FCALL                                      0  $8      
         27        SEND_VAR                                                 $8
         28        DO_ICALL                                                 
   17    29      > RETURN                                                   1

Function add:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/4OQeZ
function name:  add
number of ops:  7
compiled vars:  !0 = $a, !1 = $b
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    4     2        ADD                                              ~2      !0, !1
          3        VERIFY_RETURN_TYPE                                       ~2
          4      > RETURN                                                   ~2
    5     5*       VERIFY_RETURN_TYPE                                       
          6*     > RETURN                                                   null

End of function add

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
131.17 ms | 1403 KiB | 18 Q