3v4l.org

run code in 300+ PHP versions simultaneously
<?php function is_stringy($var){ return (is_scalar($var) and !is_bool($var)) or (is_object($var) and method_exists($var, '__toString')); } echo is_stringy('wat') ? 'true' : 'false';
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 4, Position 2 = 6
Branch analysis from position: 4
1 jumps found. (Code = 42) Position 1 = 7
Branch analysis from position: 7
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 6
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/pSVhX
function name:  (null)
number of ops:  9
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   INIT_FCALL                                               'is_stringy'
          1        SEND_VAL                                                 'wat'
          2        DO_FCALL                                      0  $0      
          3      > JMPZ                                                     $0, ->6
          4    >   QM_ASSIGN                                        ~1      'true'
          5      > JMP                                                      ->7
          6    >   QM_ASSIGN                                        ~1      'false'
          7    >   ECHO                                                     ~1
          8      > RETURN                                                   1

Function is_stringy:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 46) Position 1 = 3, Position 2 = 6
Branch analysis from position: 3
2 jumps found. (Code = 47) Position 1 = 7, Position 2 = 15
Branch analysis from position: 7
2 jumps found. (Code = 46) Position 1 = 9, Position 2 = 14
Branch analysis from position: 9
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 14
Branch analysis from position: 15
Branch analysis from position: 6
filename:       /in/pSVhX
function name:  is_stringy
number of ops:  17
compiled vars:  !0 = $var
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
    4     1        TYPE_CHECK                                  124  ~1      !0
          2      > JMPZ_EX                                          ~1      ~1, ->6
          3    >   TYPE_CHECK                                   12  ~2      !0
          4        BOOL_NOT                                         ~3      ~2
          5        BOOL                                             ~1      ~3
          6    > > JMPNZ_EX                                         ~1      ~1, ->15
          7    >   TYPE_CHECK                                  256  ~4      !0
          8      > JMPZ_EX                                          ~4      ~4, ->14
          9    >   INIT_FCALL                                               'method_exists'
         10        SEND_VAR                                                 !0
         11        SEND_VAL                                                 '__toString'
         12        DO_ICALL                                         $5      
         13        BOOL                                             ~4      $5
         14    >   BOOL                                             ~1      ~4
         15    > > RETURN                                                   ~1
    5    16*     > RETURN                                                   null

End of function is_stringy

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
151.51 ms | 1390 KiB | 16 Q