3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Post { const TABLE = 'posts'; const TYPE = 'post'; static public function all() { $select = "SELECT * FROM `%s` WHERE `type` = '%s'\n"; echo sprintf($select, self::TABLE, self::TYPE); } } Post::all(); class Comment extends Post { const TYPE = 'comment'; } Comment::all(); echo '===='; class PostA { const TABLE = 'posts'; const TYPE = 'post'; static public function all() { $select = "SELECT * FROM `%s` WHERE `type` = '%s'\n"; echo sprintf($select, static::TABLE, static::TYPE); } } PostA::all(); // SELECT * FROM `posts` WHERE `type` = 'post' class CommentA extends PostA { const TYPE = 'comment'; } CommentA::all();
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/NAq5G
function name:  (null)
number of ops:  10
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   13     0  E >   INIT_STATIC_METHOD_CALL                                  'Post', 'all'
          1        DO_FCALL                                      0          
   19     2        INIT_STATIC_METHOD_CALL                                  'Comment', 'all'
          3        DO_FCALL                                      0          
   22     4        ECHO                                                     '%3D%3D%3D%3D'
   34     5        INIT_STATIC_METHOD_CALL                                  'PostA', 'all'
          6        DO_FCALL                                      0          
   42     7        INIT_STATIC_METHOD_CALL                                  'CommentA', 'all'
          8        DO_FCALL                                      0          
          9      > RETURN                                                   1

Class Post:
Function all:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/NAq5G
function name:  all
number of ops:  8
compiled vars:  !0 = $select
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    8     0  E >   ASSIGN                                                   !0, 'SELECT+%2A+FROM+%60%25s%60+WHERE+%60type%60+%3D+%27%25s%27%0A'
    9     1        INIT_FCALL                                               'sprintf'
          2        SEND_VAR                                                 !0
          3        SEND_VAL                                                 'posts'
          4        SEND_VAL                                                 'post'
          5        DO_ICALL                                         $2      
          6        ECHO                                                     $2
   10     7      > RETURN                                                   null

End of function all

End of class Post.

Class Comment:
Function all:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/NAq5G
function name:  all
number of ops:  8
compiled vars:  !0 = $select
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    8     0  E >   ASSIGN                                                   !0, 'SELECT+%2A+FROM+%60%25s%60+WHERE+%60type%60+%3D+%27%25s%27%0A'
    9     1        INIT_FCALL                                               'sprintf'
          2        SEND_VAR                                                 !0
          3        SEND_VAL                                                 'posts'
          4        SEND_VAL                                                 'post'
          5        DO_ICALL                                         $2      
          6        ECHO                                                     $2
   10     7      > RETURN                                                   null

End of function all

End of class Comment.

Class PostA:
Function all:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/NAq5G
function name:  all
number of ops:  10
compiled vars:  !0 = $select
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   29     0  E >   ASSIGN                                                   !0, 'SELECT+%2A+FROM+%60%25s%60+WHERE+%60type%60+%3D+%27%25s%27%0A'
   30     1        INIT_FCALL                                               'sprintf'
          2        SEND_VAR                                                 !0
          3        FETCH_CLASS_CONSTANT                             ~2      'TABLE'
          4        SEND_VAL                                                 ~2
          5        FETCH_CLASS_CONSTANT                             ~3      'TYPE'
          6        SEND_VAL                                                 ~3
          7        DO_ICALL                                         $4      
          8        ECHO                                                     $4
   31     9      > RETURN                                                   null

End of function all

End of class PostA.

Class CommentA:
Function all:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/NAq5G
function name:  all
number of ops:  10
compiled vars:  !0 = $select
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   29     0  E >   ASSIGN                                                   !0, 'SELECT+%2A+FROM+%60%25s%60+WHERE+%60type%60+%3D+%27%25s%27%0A'
   30     1        INIT_FCALL                                               'sprintf'
          2        SEND_VAR                                                 !0
          3        FETCH_CLASS_CONSTANT                             ~2      'TABLE'
          4        SEND_VAL                                                 ~2
          5        FETCH_CLASS_CONSTANT                             ~3      'TYPE'
          6        SEND_VAL                                                 ~3
          7        DO_ICALL                                         $4      
          8        ECHO                                                     $4
   31     9      > RETURN                                                   null

End of function all

End of class CommentA.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
154.9 ms | 1392 KiB | 15 Q