3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php function truthy($value){ return in_array($value, array(true,1,'y','yes','true'), true); } var_dump(truthy('n')); var_dump(truthy('yes')); var_dump(truthy('no')); var_dump(truthy('false')); var_dump(truthy(false));
based on KKBDf
Finding entry points
Branch analysis from position: 0
Jump found. Position 1 = -2
filename:       /in/D4GD5
function name:  (null)
number of ops:  32
compiled vars:  none
line     #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   3     0  E >   NOP                                                      
   8     1        INIT_FCALL                                               'var_dump'
         2        INIT_FCALL                                               'truthy'
         3        SEND_VAL                                                 'n'
         4        DO_FCALL                                      0  $0      
         5        SEND_VAR                                                 $0
         6        DO_ICALL                                                 
   9     7        INIT_FCALL                                               'var_dump'
         8        INIT_FCALL                                               'truthy'
         9        SEND_VAL                                                 'yes'
        10        DO_FCALL                                      0  $2      
        11        SEND_VAR                                                 $2
        12        DO_ICALL                                                 
  10    13        INIT_FCALL                                               'var_dump'
        14        INIT_FCALL                                               'truthy'
        15        SEND_VAL                                                 'no'
        16        DO_FCALL                                      0  $4      
        17        SEND_VAR                                                 $4
        18        DO_ICALL                                                 
  11    19        INIT_FCALL                                               'var_dump'
        20        INIT_FCALL                                               'truthy'
        21        SEND_VAL                                                 'false'
        22        DO_FCALL                                      0  $6      
        23        SEND_VAR                                                 $6
        24        DO_ICALL                                                 
  12    25        INIT_FCALL                                               'var_dump'
        26        INIT_FCALL                                               'truthy'
        27        SEND_VAL                                                 <false>
        28        DO_FCALL                                      0  $8      
        29        SEND_VAR                                                 $8
        30        DO_ICALL                                                 
        31      > RETURN                                                   1

Function truthy:
Finding entry points
Branch analysis from position: 0
Jump found. Position 1 = -2
filename:       /in/D4GD5
function name:  truthy
number of ops:  8
compiled vars:  !0 = $value
line     #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   3     0  E >   RECV                                             !0      
   4     1        INIT_FCALL                                               'in_array'
         2        SEND_VAR                                                 !0
         3        SEND_VAL                                                 <array>
         4        SEND_VAL                                                 <true>
         5        DO_ICALL                                         $1      
         6      > RETURN                                                   $1
   5     7*     > RETURN                                                   null

End of function truthy

Generated using Vulcan Logic Dumper, using php 7.2.0