3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Foo { private $a; protected $b; public $c; } class FooCountable implements \Countable { private $elements = [1,2,3]; public function count() { return count($this->elements); } } $tests = [ 'array' => [1,2,3], 'string' => 'hello world', 'number' => 123, 'iterator' => new \ArrayIterator([1,2,3]), 'countable' => new \FooCountable(), 'zero' => 0, 'string_zero' => '0', 'object' => new \Foo(), 'stdClass' => new \stdClass, 'null' => null, 'empty' => '', 'boolt' => true, 'boolf' => false ]; foreach($tests as $key => $test) { echo $key . ': ' . print_r(@count($test), 1) . \PHP_EOL; } echo '---' . \PHP_EOL; echo 'Undefined: ' . @count($undefinedVariable);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 25, Position 2 = 39
Branch analysis from position: 25
2 jumps found. (Code = 78) Position 1 = 26, Position 2 = 39
Branch analysis from position: 26
1 jumps found. (Code = 42) Position 1 = 25
Branch analysis from position: 25
Branch analysis from position: 39
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 39
filename:       /in/nmWmE
function name:  (null)
number of ops:  47
compiled vars:  !0 = $tests, !1 = $test, !2 = $key, !3 = $undefinedVariable
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   10     0  E >   DECLARE_CLASS                                            'foocountable'
   21     1        INIT_ARRAY                                       ~4      <array>, 'array'
   22     2        ADD_ARRAY_ELEMENT                                ~4      'hello+world', 'string'
   23     3        ADD_ARRAY_ELEMENT                                ~4      123, 'number'
   24     4        NEW                                              $5      'ArrayIterator'
          5        SEND_VAL_EX                                              <array>
          6        DO_FCALL                                      0          
          7        ADD_ARRAY_ELEMENT                                ~4      $5, 'iterator'
   25     8        NEW                                              $7      'FooCountable'
          9        DO_FCALL                                      0          
         10        ADD_ARRAY_ELEMENT                                ~4      $7, 'countable'
   26    11        ADD_ARRAY_ELEMENT                                ~4      0, 'zero'
   27    12        ADD_ARRAY_ELEMENT                                ~4      '0', 'string_zero'
   28    13        NEW                                              $9      'Foo'
         14        DO_FCALL                                      0          
         15        ADD_ARRAY_ELEMENT                                ~4      $9, 'object'
   29    16        NEW                                              $11     'stdClass'
         17        DO_FCALL                                      0          
         18        ADD_ARRAY_ELEMENT                                ~4      $11, 'stdClass'
   21    19        ADD_ARRAY_ELEMENT                                ~4      null, 'null'
   31    20        ADD_ARRAY_ELEMENT                                ~4      '', 'empty'
   21    21        ADD_ARRAY_ELEMENT                                ~4      <true>, 'boolt'
         22        ADD_ARRAY_ELEMENT                                ~4      <false>, 'boolf'
   20    23        ASSIGN                                                   !0, ~4
   36    24      > FE_RESET_R                                       $14     !0, ->39
         25    > > FE_FETCH_R                                       ~15     $14, !1, ->39
         26    >   ASSIGN                                                   !2, ~15
   37    27        CONCAT                                           ~17     !2, '%3A+'
         28        INIT_FCALL                                               'print_r'
         29        BEGIN_SILENCE                                    ~18     
         30        COUNT                                            ~19     !1
         31        END_SILENCE                                              ~18
         32        SEND_VAL                                                 ~19
         33        SEND_VAL                                                 1
         34        DO_ICALL                                         $20     
         35        CONCAT                                           ~21     ~17, $20
         36        CONCAT                                           ~22     ~21, '%0A'
         37        ECHO                                                     ~22
   36    38      > JMP                                                      ->25
         39    >   FE_FREE                                                  $14
   39    40        ECHO                                                     '---%0A'
   40    41        BEGIN_SILENCE                                    ~23     
         42        COUNT                                            ~24     !3
         43        END_SILENCE                                              ~23
         44        CONCAT                                           ~25     'Undefined%3A+', ~24
         45        ECHO                                                     ~25
         46      > RETURN                                                   1

Class Foo: [no user functions]
Class FooCountable:
Function count:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/nmWmE
function name:  count
number of ops:  4
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   16     0  E >   FETCH_OBJ_R                                      ~0      'elements'
          1        COUNT                                            ~1      ~0
          2      > RETURN                                                   ~1
   17     3*     > RETURN                                                   null

End of function count

End of class FooCountable.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
126.39 ms | 1405 KiB | 15 Q