3v4l.org

run code in 300+ PHP versions simultaneously
<?php // Declara a interface 'iTemplate' interface iTemplate { public function setVariable($name, $var); public function getHtml($template); } // Implementa a interface // Isso funcionará class Template implements iTemplate { private $vars = array(); public function setVariable($name, $var) { $this->vars[$name] = $var; } public function getHtml($template) { foreach($this->vars as $name => $value) { $template = str_replace('{' . $name . '}', $value, $template); } return $template; } } // Isso NÃO funcionará // Fatal error: Class BadTemplate contains 1 abstract methods // and must therefore be declared abstract (iTemplate::getHtml) class BadTemplate extends Template { private $vars = array(); } ?>
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/rMeE3
function name:  (null)
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   12     0  E >   DECLARE_CLASS                                            'template'
   34     1        DECLARE_CLASS                                            'badtemplate', 'template'
   39     2      > RETURN                                                   1

Class iTemplate:
Function setvariable:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/rMeE3
function name:  setVariable
number of ops:  3
compiled vars:  !0 = $name, !1 = $var
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2      > RETURN                                                   null

End of function setvariable

Function gethtml:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/rMeE3
function name:  getHtml
number of ops:  2
compiled vars:  !0 = $template
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   RECV                                             !0      
          1      > RETURN                                                   null

End of function gethtml

End of class iTemplate.

Class Template:
Function setvariable:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/rMeE3
function name:  setVariable
number of ops:  6
compiled vars:  !0 = $name, !1 = $var
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   16     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   18     2        FETCH_OBJ_W                                      $2      'vars'
          3        ASSIGN_DIM                                               $2, !0
          4        OP_DATA                                                  !1
   19     5      > RETURN                                                   null

End of function setvariable

Function gethtml:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 3, Position 2 = 14
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 14
Branch analysis from position: 4
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 14
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 14
filename:       /in/rMeE3
function name:  getHtml
number of ops:  17
compiled vars:  !0 = $template, !1 = $value, !2 = $name
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   21     0  E >   RECV                                             !0      
   23     1        FETCH_OBJ_R                                      ~3      'vars'
          2      > FE_RESET_R                                       $4      ~3, ->14
          3    > > FE_FETCH_R                                       ~5      $4, !1, ->14
          4    >   ASSIGN                                                   !2, ~5
   24     5        INIT_FCALL                                               'str_replace'
          6        CONCAT                                           ~7      '%7B', !2
          7        CONCAT                                           ~8      ~7, '%7D'
          8        SEND_VAL                                                 ~8
          9        SEND_VAR                                                 !1
         10        SEND_VAR                                                 !0
         11        DO_ICALL                                         $9      
         12        ASSIGN                                                   !0, $9
   23    13      > JMP                                                      ->3
         14    >   FE_FREE                                                  $4
   27    15      > RETURN                                                   !0
   28    16*     > RETURN                                                   null

End of function gethtml

End of class Template.

Class BadTemplate: [no user functions]

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
158.23 ms | 1392 KiB | 15 Q