3v4l.org

run code in 300+ PHP versions simultaneously
<?php /*$tests = [ '[] == false' => [] == false, '[0] == true' => [0] == true, '"" == false' => '' == false, '"ABC" == false' => 'ABC' == false, '"0" == false' => '0' == false, '"1" == true' => '1' == true, '"123" == false' => '123' == true, 'null == false' => null == false, '0 == false' => 0 == false, '0.49 == false' => 0.49 == false, 'undefined == false' => $xyz == false ];*/ function _setType($var, $type) { settype($var, $type); return $var; } function testTypeCasting($val) { static $types = ["bool", "int", "float", "string", "array", "object", "null"]; $result = []; foreach ($types as $type) { $result[$type] = _setType($val, $type); } return $result; } var_dump(testTypeCasting("777.777")); /* $i = 0; foreach($tests as $name => $val) { echo ++$i . ') ' . $name . ' => ' . ($val ? 'T' : 'F') . "\n"; } */
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/iKjjV
function name:  (null)
number of ops:  7
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   32     0  E >   INIT_FCALL                                               'var_dump'
          1        INIT_FCALL                                               'testtypecasting'
          2        SEND_VAL                                                 '777.777'
          3        DO_FCALL                                      0  $0      
          4        SEND_VAR                                                 $0
          5        DO_ICALL                                                 
   39     6      > RETURN                                                   1

Function _settype:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/iKjjV
function name:  _setType
number of ops:  8
compiled vars:  !0 = $var, !1 = $type
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   17     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   19     2        INIT_FCALL                                               'settype'
          3        SEND_REF                                                 !0
          4        SEND_VAR                                                 !1
          5        DO_ICALL                                                 
   20     6      > RETURN                                                   !0
   21     7*     > RETURN                                                   null

End of function _settype

Function testtypecasting:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 4, Position 2 = 12
Branch analysis from position: 4
2 jumps found. (Code = 78) Position 1 = 5, Position 2 = 12
Branch analysis from position: 5
1 jumps found. (Code = 42) Position 1 = 4
Branch analysis from position: 4
Branch analysis from position: 12
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 12
filename:       /in/iKjjV
function name:  testTypeCasting
number of ops:  15
compiled vars:  !0 = $val, !1 = $types, !2 = $result, !3 = $type
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   22     0  E >   RECV                                             !0      
   24     1        BIND_STATIC                                              !1
   25     2        ASSIGN                                                   !2, <array>
   26     3      > FE_RESET_R                                       $5      !1, ->12
          4    > > FE_FETCH_R                                               $5, !3, ->12
   27     5    >   INIT_FCALL                                               '_settype'
          6        SEND_VAR                                                 !0
          7        SEND_VAR                                                 !3
          8        DO_FCALL                                      0  $7      
          9        ASSIGN_DIM                                               !2, !3
         10        OP_DATA                                                  $7
   26    11      > JMP                                                      ->4
         12    >   FE_FREE                                                  $5
   29    13      > RETURN                                                   !2
   30    14*     > RETURN                                                   null

End of function testtypecasting

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
153.6 ms | 1399 KiB | 19 Q