3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Fails { private $dir; public function __construct($dir) { $this->dir = @opendir($dir); // Different resource everytime } } var_dump(new Fails('/tmp') == new Fails('/tmp')); // Actual failure var_dump(opendir('/tmp') == opendir('/tmp')); // This works, because no member variable with a different value is assigned class Works { private $dir; public function __construct($dir) { $this->dir = $dir; } } var_dump(new Works('/tmp') == new Works('/tmp'));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/r10A4
function name:  (null)
number of ops:  31
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   10     0  E >   INIT_FCALL                                               'var_dump'
          1        NEW                                              $0      'Fails'
          2        SEND_VAL_EX                                              '%2Ftmp'
          3        DO_FCALL                                      0          
          4        NEW                                              $2      'Fails'
          5        SEND_VAL_EX                                              '%2Ftmp'
          6        DO_FCALL                                      0          
          7        IS_EQUAL                                         ~4      $0, $2
          8        SEND_VAL                                                 ~4
          9        DO_ICALL                                                 
   14    10        INIT_FCALL                                               'var_dump'
         11        INIT_FCALL                                               'opendir'
         12        SEND_VAL                                                 '%2Ftmp'
         13        DO_ICALL                                         $6      
         14        INIT_FCALL                                               'opendir'
         15        SEND_VAL                                                 '%2Ftmp'
         16        DO_ICALL                                         $7      
         17        IS_EQUAL                                         ~8      $6, $7
         18        SEND_VAL                                                 ~8
         19        DO_ICALL                                                 
   25    20        INIT_FCALL                                               'var_dump'
         21        NEW                                              $10     'Works'
         22        SEND_VAL_EX                                              '%2Ftmp'
         23        DO_FCALL                                      0          
         24        NEW                                              $12     'Works'
         25        SEND_VAL_EX                                              '%2Ftmp'
         26        DO_FCALL                                      0          
         27        IS_EQUAL                                         ~14     $10, $12
         28        SEND_VAL                                                 ~14
         29        DO_ICALL                                                 
         30      > RETURN                                                   1

Class Fails:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/r10A4
function name:  __construct
number of ops:  9
compiled vars:  !0 = $dir
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   RECV                                             !0      
    6     1        BEGIN_SILENCE                                    ~2      
          2        INIT_FCALL                                               'opendir'
          3        SEND_VAR                                                 !0
          4        DO_ICALL                                         $3      
          5        END_SILENCE                                              ~2
          6        ASSIGN_OBJ                                               'dir'
          7        OP_DATA                                                  $3
    7     8      > RETURN                                                   null

End of function __construct

End of class Fails.

Class Works:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/r10A4
function name:  __construct
number of ops:  4
compiled vars:  !0 = $dir
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   20     0  E >   RECV                                             !0      
   21     1        ASSIGN_OBJ                                               'dir'
          2        OP_DATA                                                  !0
   22     3      > RETURN                                                   null

End of function __construct

End of class Works.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
170.89 ms | 1400 KiB | 17 Q