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) { $temp = _setType($val, $type); if ($type === 'object') { $type .= '(' . get_class($temp) . ')'; } $result[$type] = $temp; } return $result; } var_dump(testTypeCasting([123, 'b', 'c'])); var_dump( null == 'php', 'php' == null ); var_dump( 1 == 1.7, 1.7 == 1 ); /* $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/qJDIv
function name:  (null)
number of ops:  15
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   36     0  E >   INIT_FCALL                                               'var_dump'
          1        INIT_FCALL                                               'testtypecasting'
          2        SEND_VAL                                                 <array>
          3        DO_FCALL                                      0  $0      
          4        SEND_VAR                                                 $0
          5        DO_ICALL                                                 
   38     6        INIT_FCALL                                               'var_dump'
   39     7        SEND_VAL                                                 <false>
   40     8        SEND_VAL                                                 <false>
          9        DO_ICALL                                                 
   43    10        INIT_FCALL                                               'var_dump'
   44    11        SEND_VAL                                                 <false>
   45    12        SEND_VAL                                                 <false>
         13        DO_ICALL                                                 
   53    14      > RETURN                                                   1

Function _settype:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/qJDIv
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 = 19
Branch analysis from position: 4
2 jumps found. (Code = 78) Position 1 = 5, Position 2 = 19
Branch analysis from position: 5
2 jumps found. (Code = 43) Position 1 = 12, Position 2 = 16
Branch analysis from position: 12
1 jumps found. (Code = 42) Position 1 = 4
Branch analysis from position: 4
Branch analysis from position: 16
Branch analysis from position: 19
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 19
filename:       /in/qJDIv
function name:  testTypeCasting
number of ops:  22
compiled vars:  !0 = $val, !1 = $types, !2 = $result, !3 = $type, !4 = $temp
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                                       $6      !1, ->19
          4    > > FE_FETCH_R                                               $6, !3, ->19
   27     5    >   INIT_FCALL                                               '_settype'
          6        SEND_VAR                                                 !0
          7        SEND_VAR                                                 !3
          8        DO_FCALL                                      0  $7      
          9        ASSIGN                                                   !4, $7
   28    10        IS_IDENTICAL                                             !3, 'object'
         11      > JMPZ                                                     ~9, ->16
   29    12    >   GET_CLASS                                        ~10     !4
         13        CONCAT                                           ~11     '%28', ~10
         14        CONCAT                                           ~12     ~11, '%29'
         15        ASSIGN_OP                                     8          !3, ~12
   31    16    >   ASSIGN_DIM                                               !2, !3
         17        OP_DATA                                                  !4
   26    18      > JMP                                                      ->4
         19    >   FE_FREE                                                  $6
   33    20      > RETURN                                                   !2
   34    21*     > RETURN                                                   null

End of function testtypecasting

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
168.03 ms | 1402 KiB | 19 Q