3v4l.org

run code in 300+ PHP versions simultaneously
<?php error_reporting(E_ALL); ?><!doctype html> <html> <head> <meta charset="utf-8"> <title>PHP comparisions</title> <style> table { border-collapse: collapse; } th, td { margin: 0; padding: 7px; border: 1px solid #ddd; } th { font-weight: normal; } tbody th { text-align: left; } td { text-align: center; } span.true { color: green; } span.false { color: red; } </style> </head> <body> <?php $values = array( '0', '""', '"0"', 'null', 'false', 'array()', 'array(null)', 'array(false)', 'array(0)', 'array("0")' ); ?><table> <thead><tr> <th></th> <th>if(...)</th> <th>empty</th> <th>is_null</th> <th>is_numeric</th> <?php for($i = 0; $i < count($values); $i++) { $Vi = getValue($values, $i); ?><th>== <?php echo formatValue($Vi); ?></th><?php ?><th>=== <?php echo formatValue($Vi); ?></th><?php } ?> </tr></thead> <tbody><?php for($i = 0; $i < count($values); $i++) { $Vi = getValue($values, $i); ?><tr> <th><?php echo formatValue($Vi); ?></th> <td><?php echo formatCompare($Vi); ?></td> <td><?php echo formatCompare(empty($Vi)); ?></td> <td><?php echo formatCompare(is_null($Vi)); ?></td> <td><?php echo formatCompare(is_numeric($Vi)); ?></td> <?php for($j = 0; $j < count($values); $j++) { $Vj = getValue($values, $j); ?> <td><?php echo formatCompare($Vi == $Vj); ?></td> <td><?php echo formatCompare($Vi === $Vj); ?></td> <?php } ?> </tr><?php } ?></tbody> </table> </body> </html><?php function getValue($values, $index) { eval('$v = ' . $values[$index] . ';'); return $v; } function formatValue($o) { switch(gettype($o)) { case 'integer': $result = $o; break; case 'string': $result = '"' . addslashes($o) . '"'; break; case 'NULL': $result = 'null'; break; case 'boolean': $result = $o ? 'true' : 'false'; break; case 'array': $values = array(); foreach($o as $v) { $values[] = formatValue($v); } $result = 'array(' . implode(', ', $values) . ')'; break; default: die(gettype($o)); } return $result; } function formatCompare($criteria) { if($criteria) { return '<span class="true">&#x2713;</span>'; } else { return '<span class="false">&#x2717;</span>'; } }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 26
Branch analysis from position: 26
2 jumps found. (Code = 44) Position 1 = 29, Position 2 = 8
Branch analysis from position: 29
1 jumps found. (Code = 42) Position 1 = 94
Branch analysis from position: 94
2 jumps found. (Code = 44) Position 1 = 97, Position 2 = 32
Branch analysis from position: 97
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 32
1 jumps found. (Code = 42) Position 1 = 89
Branch analysis from position: 89
2 jumps found. (Code = 44) Position 1 = 92, Position 2 = 70
Branch analysis from position: 92
2 jumps found. (Code = 44) Position 1 = 97, Position 2 = 32
Branch analysis from position: 97
Branch analysis from position: 32
Branch analysis from position: 70
2 jumps found. (Code = 44) Position 1 = 92, Position 2 = 70
Branch analysis from position: 92
Branch analysis from position: 70
Branch analysis from position: 8
2 jumps found. (Code = 44) Position 1 = 29, Position 2 = 8
Branch analysis from position: 29
Branch analysis from position: 8
filename:       /in/DAaQ6
function name:  (null)
number of ops:  99
compiled vars:  !0 = $values, !1 = $i, !2 = $Vi, !3 = $j, !4 = $Vj
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    1     0  E >   INIT_FCALL                                               'error_reporting'
          1        SEND_VAL                                                 32767
          2        DO_ICALL                                                 
          3        ECHO                                                     '%3C%21doctype+html%3E%0A%3Chtml%3E%0A%3Chead%3E%0A%3Cmeta+charset%3D%22utf-8%22%3E%0A%3Ctitle%3EPHP+comparisions%3C%2Ftitle%3E%0A%3Cstyle%3E%0Atable+%7B%0A%09border-collapse%3A+collapse%3B%0A%7D%0Ath%2C+td+%7B%0A%09margin%3A+0%3B%0A%09padding%3A+7px%3B%0A%09border%3A+1px+solid+%23ddd%3B%0A%7D%0Ath+%7B%0A%09font-weight%3A+normal%3B%0A%7D%0Atbody+th+%7B%0A%09text-align%3A+left%3B%0A%7D%0Atd+%7B%0A%09text-align%3A+center%3B%0A%7D%0Aspan.true+%7B%0A%09color%3A+green%3B%0A%7D%0Aspan.false+%7B%0A%09color%3A+red%3B%0A%7D%0A%0A%3C%2Fstyle%3E%0A%3C%2Fhead%3E%0A%3Cbody%3E%0A'
   35     4        ASSIGN                                                   !0, <array>
   47     5        ECHO                                                     '%3Ctable%3E%0A%09%3Cthead%3E%3Ctr%3E%0A%09%09%3Cth%3E%3C%2Fth%3E%0A%09%09%3Cth%3Eif%28...%29%3C%2Fth%3E%0A%09%09%3Cth%3Eempty%3C%2Fth%3E%0A%09%09%3Cth%3Eis_null%3C%2Fth%3E%0A%09%09%3Cth%3Eis_numeric%3C%2Fth%3E%0A%09%09'
   55     6        ASSIGN                                                   !1, 0
          7      > JMP                                                      ->26
   56     8    >   INIT_FCALL_BY_NAME                                       'getValue'
          9        SEND_VAR_EX                                              !0
         10        SEND_VAR_EX                                              !1
         11        DO_FCALL                                      0  $8      
         12        ASSIGN                                                   !2, $8
   57    13        ECHO                                                     '%3Cth%3E%3D%3D+'
         14        INIT_FCALL_BY_NAME                                       'formatValue'
         15        SEND_VAR_EX                                              !2
         16        DO_FCALL                                      0  $10     
         17        ECHO                                                     $10
         18        ECHO                                                     '%3C%2Fth%3E'
   58    19        ECHO                                                     '%3Cth%3E%3D%3D%3D+'
         20        INIT_FCALL_BY_NAME                                       'formatValue'
         21        SEND_VAR_EX                                              !2
         22        DO_FCALL                                      0  $11     
         23        ECHO                                                     $11
         24        ECHO                                                     '%3C%2Fth%3E'
   55    25        PRE_INC                                                  !1
         26    >   COUNT                                            ~13     !0
         27        IS_SMALLER                                               !1, ~13
         28      > JMPNZ                                                    ~14, ->8
   61    29    >   ECHO                                                     '%09%3C%2Ftr%3E%3C%2Fthead%3E%0A%09%3Ctbody%3E'
   63    30        ASSIGN                                                   !1, 0
         31      > JMP                                                      ->94
   64    32    >   INIT_FCALL_BY_NAME                                       'getValue'
         33        SEND_VAR_EX                                              !0
         34        SEND_VAR_EX                                              !1
         35        DO_FCALL                                      0  $16     
         36        ASSIGN                                                   !2, $16
   65    37        ECHO                                                     '%3Ctr%3E%0A%09%09%09%09%3Cth%3E'
   66    38        INIT_FCALL_BY_NAME                                       'formatValue'
         39        SEND_VAR_EX                                              !2
         40        DO_FCALL                                      0  $18     
         41        ECHO                                                     $18
         42        ECHO                                                     '%3C%2Fth%3E%0A%09%09%09%09%3Ctd%3E'
   67    43        INIT_FCALL_BY_NAME                                       'formatCompare'
         44        SEND_VAR_EX                                              !2
         45        DO_FCALL                                      0  $19     
         46        ECHO                                                     $19
         47        ECHO                                                     '%3C%2Ftd%3E%0A%09%09%09%09%3Ctd%3E'
   68    48        INIT_FCALL_BY_NAME                                       'formatCompare'
         49        ISSET_ISEMPTY_CV                                 ~20     !2
         50        SEND_VAL_EX                                              ~20
         51        DO_FCALL                                      0  $21     
         52        ECHO                                                     $21
         53        ECHO                                                     '%3C%2Ftd%3E%0A%09%09%09%09%3Ctd%3E'
   69    54        INIT_FCALL_BY_NAME                                       'formatCompare'
         55        TYPE_CHECK                                    2  ~22     !2
         56        SEND_VAL_EX                                              ~22
         57        DO_FCALL                                      0  $23     
         58        ECHO                                                     $23
         59        ECHO                                                     '%3C%2Ftd%3E%0A%09%09%09%09%3Ctd%3E'
   70    60        INIT_FCALL_BY_NAME                                       'formatCompare'
         61        INIT_FCALL                                               'is_numeric'
         62        SEND_VAR                                                 !2
         63        DO_ICALL                                         $24     
         64        SEND_VAR_NO_REF_EX                                       $24
         65        DO_FCALL                                      0  $25     
         66        ECHO                                                     $25
         67        ECHO                                                     '%3C%2Ftd%3E%0A%09%09%09%09'
   72    68        ASSIGN                                                   !3, 0
         69      > JMP                                                      ->89
   73    70    >   INIT_FCALL_BY_NAME                                       'getValue'
         71        SEND_VAR_EX                                              !0
         72        SEND_VAR_EX                                              !3
         73        DO_FCALL                                      0  $27     
         74        ASSIGN                                                   !4, $27
   75    75        ECHO                                                     '%09%09%09%09%09%3Ctd%3E'
         76        INIT_FCALL_BY_NAME                                       'formatCompare'
         77        IS_EQUAL                                         ~29     !2, !4
         78        SEND_VAL_EX                                              ~29
         79        DO_FCALL                                      0  $30     
         80        ECHO                                                     $30
         81        ECHO                                                     '%3C%2Ftd%3E%0A%09%09%09%09%09%3Ctd%3E'
   76    82        INIT_FCALL_BY_NAME                                       'formatCompare'
         83        IS_IDENTICAL                                     ~31     !2, !4
         84        SEND_VAL_EX                                              ~31
         85        DO_FCALL                                      0  $32     
         86        ECHO                                                     $32
         87        ECHO                                                     '%3C%2Ftd%3E%0A%09%09%09%09%09'
   72    88        PRE_INC                                                  !3
         89    >   COUNT                                            ~34     !0
         90        IS_SMALLER                                               !3, ~34
         91      > JMPNZ                                                    ~35, ->70
   80    92    >   ECHO                                                     '%09%09%09%3C%2Ftr%3E'
   63    93        PRE_INC                                                  !1
         94    >   COUNT                                            ~37     !0
         95        IS_SMALLER                                               !1, ~37
         96      > JMPNZ                                                    ~38, ->32
   82    97    >   ECHO                                                     '%3C%2Ftbody%3E%0A%3C%2Ftable%3E%0A%3C%2Fbody%3E%0A%3C%2Fhtml%3E'
  126    98      > RETURN                                                   1

Function getvalue:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/DAaQ6
function name:  getValue
number of ops:  8
compiled vars:  !0 = $values, !1 = $index, !2 = $v
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   87     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   88     2        FETCH_DIM_R                                      ~3      !0, !1
          3        CONCAT                                           ~4      '%24v+%3D+', ~3
          4        CONCAT                                           ~5      ~4, '%3B'
          5        INCLUDE_OR_EVAL                                          ~5, EVAL
   89     6      > RETURN                                                   !2
   90     7*     > RETURN                                                   null

End of function getvalue

Function formatvalue:
Finding entry points
Branch analysis from position: 0
7 jumps found. (Code = 188) Position 1 = 14, Position 2 = 16, Position 3 = 23, Position 4 = 25, Position 5 = 31, Position 6 = 49, Position 7 = 3
Branch analysis from position: 14
1 jumps found. (Code = 42) Position 1 = 51
Branch analysis from position: 51
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 16
1 jumps found. (Code = 42) Position 1 = 51
Branch analysis from position: 51
Branch analysis from position: 23
1 jumps found. (Code = 42) Position 1 = 51
Branch analysis from position: 51
Branch analysis from position: 25
2 jumps found. (Code = 43) Position 1 = 26, Position 2 = 28
Branch analysis from position: 26
1 jumps found. (Code = 42) Position 1 = 29
Branch analysis from position: 29
1 jumps found. (Code = 42) Position 1 = 51
Branch analysis from position: 51
Branch analysis from position: 28
1 jumps found. (Code = 42) Position 1 = 51
Branch analysis from position: 51
Branch analysis from position: 31
2 jumps found. (Code = 77) Position 1 = 33, Position 2 = 40
Branch analysis from position: 33
2 jumps found. (Code = 78) Position 1 = 34, Position 2 = 40
Branch analysis from position: 34
1 jumps found. (Code = 42) Position 1 = 33
Branch analysis from position: 33
Branch analysis from position: 40
1 jumps found. (Code = 42) Position 1 = 51
Branch analysis from position: 51
Branch analysis from position: 40
Branch analysis from position: 49
1 jumps found. (Code = 79) Position 1 = -2
Branch analysis from position: 3
2 jumps found. (Code = 44) Position 1 = 5, Position 2 = 14
Branch analysis from position: 5
2 jumps found. (Code = 44) Position 1 = 7, Position 2 = 16
Branch analysis from position: 7
2 jumps found. (Code = 44) Position 1 = 9, Position 2 = 23
Branch analysis from position: 9
2 jumps found. (Code = 44) Position 1 = 11, Position 2 = 25
Branch analysis from position: 11
2 jumps found. (Code = 44) Position 1 = 13, Position 2 = 31
Branch analysis from position: 13
1 jumps found. (Code = 42) Position 1 = 49
Branch analysis from position: 49
Branch analysis from position: 31
Branch analysis from position: 25
Branch analysis from position: 23
Branch analysis from position: 16
Branch analysis from position: 14
filename:       /in/DAaQ6
function name:  formatValue
number of ops:  54
compiled vars:  !0 = $o, !1 = $result, !2 = $values, !3 = $v
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   92     0  E >   RECV                                             !0      
   93     1        GET_TYPE                                         ~4      !0
          2      > SWITCH_STRING                                            ~4, [ 'integer':->14, 'string':->16, 'NULL':->23, 'boolean':->25, 'array':->31, ], ->49
   94     3    >   CASE                                                     ~4, 'integer'
          4      > JMPNZ                                                    ~5, ->14
   97     5    >   CASE                                                     ~4, 'string'
          6      > JMPNZ                                                    ~5, ->16
  100     7    >   CASE                                                     ~4, 'NULL'
          8      > JMPNZ                                                    ~5, ->23
  103     9    >   CASE                                                     ~4, 'boolean'
         10      > JMPNZ                                                    ~5, ->25
  106    11    >   CASE                                                     ~4, 'array'
         12      > JMPNZ                                                    ~5, ->31
         13    > > JMP                                                      ->49
   95    14    >   ASSIGN                                                   !1, !0
   96    15      > JMP                                                      ->51
   98    16    >   INIT_FCALL                                               'addslashes'
         17        SEND_VAR                                                 !0
         18        DO_ICALL                                         $7      
         19        CONCAT                                           ~8      '%22', $7
         20        CONCAT                                           ~9      ~8, '%22'
         21        ASSIGN                                                   !1, ~9
   99    22      > JMP                                                      ->51
  101    23    >   ASSIGN                                                   !1, 'null'
  102    24      > JMP                                                      ->51
  104    25    > > JMPZ                                                     !0, ->28
         26    >   QM_ASSIGN                                        ~12     'true'
         27      > JMP                                                      ->29
         28    >   QM_ASSIGN                                        ~12     'false'
         29    >   ASSIGN                                                   !1, ~12
  105    30      > JMP                                                      ->51
  107    31    >   ASSIGN                                                   !2, <array>
  108    32      > FE_RESET_R                                       $15     !0, ->40
         33    > > FE_FETCH_R                                               $15, !3, ->40
  109    34    >   INIT_FCALL_BY_NAME                                       'formatValue'
         35        SEND_VAR_EX                                              !3
         36        DO_FCALL                                      0  $17     
         37        ASSIGN_DIM                                               !2
         38        OP_DATA                                                  $17
  108    39      > JMP                                                      ->33
         40    >   FE_FREE                                                  $15
  111    41        INIT_FCALL                                               'implode'
         42        SEND_VAL                                                 '%2C+'
         43        SEND_VAR                                                 !2
         44        DO_ICALL                                         $18     
         45        CONCAT                                           ~19     'array%28', $18
         46        CONCAT                                           ~20     ~19, '%29'
         47        ASSIGN                                                   !1, ~20
  112    48      > JMP                                                      ->51
  114    49    >   GET_TYPE                                         ~22     !0
         50      > EXIT                                                     ~22
         51    >   FREE                                                     ~4
  116    52      > RETURN                                                   !1
  117    53*     > RETURN                                                   null

End of function formatvalue

Function formatcompare:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 2, Position 2 = 4
Branch analysis from position: 2
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 4
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/DAaQ6
function name:  formatCompare
number of ops:  6
compiled vars:  !0 = $criteria
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  119     0  E >   RECV                                             !0      
  120     1      > JMPZ                                                     !0, ->4
  121     2    > > RETURN                                                   '%3Cspan+class%3D%22true%22%3E%26%23x2713%3B%3C%2Fspan%3E'
          3*       JMP                                                      ->5
  124     4    > > RETURN                                                   '%3Cspan+class%3D%22false%22%3E%26%23x2717%3B%3C%2Fspan%3E'
  126     5*     > RETURN                                                   null

End of function formatcompare

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
157.57 ms | 1412 KiB | 21 Q