3v4l.org

run code in 300+ PHP versions simultaneously
<?php class FormBuilder { private function __construct() {} public static function build($form_attributes, $input_attributes) { $content = ''; foreach ($input_attributes as $key => $value) { $content = $content . '\n' + $this::buildInput($key, $value); } list($action, $method) = form_attributes; return $this::buildForm($content, $action, $method); } private static function buildInput($id, $name) { return "<div class=''> <label for='{$id}' class=''>{$name} <input type='text' name='{$name}' id='{$id}' class=''> </label> </div>"; } private static function buildForm($content, $action = '', $method = 'post') { return "<form action='{$action}' class='' method='{$method}'> {$content} </form>"; } private static function callback($key, $value) { buildInput($key, $value); } } $names = array( 'user' => 'Username', 'email' => 'Email', 'fname' => 'First Name', 'lname' => 'Last Name', 'pass' => 'Password', 'confirmedpass' => 'Confirmed Password' ); $form_attributes = [ 'action' => '', 'method' => 'post' ];
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/NEnf5
function name:  (null)
number of ops:  3
compiled vars:  !0 = $names, !1 = $form_attributes
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   38     0  E >   ASSIGN                                                   !0, <array>
   47     1        ASSIGN                                                   !1, <array>
   50     2      > RETURN                                                   1

Class FormBuilder:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/NEnf5
function name:  __construct
number of ops:  1
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E > > RETURN                                                   null

End of function __construct

Function build:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 4, Position 2 = 16
Branch analysis from position: 4
2 jumps found. (Code = 78) Position 1 = 5, Position 2 = 16
Branch analysis from position: 5
1 jumps found. (Code = 42) Position 1 = 4
Branch analysis from position: 4
Branch analysis from position: 16
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 16
filename:       /in/NEnf5
function name:  build
number of ops:  32
compiled vars:  !0 = $form_attributes, !1 = $input_attributes, !2 = $content, !3 = $value, !4 = $key, !5 = $action, !6 = $method
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    7     2        ASSIGN                                                   !2, ''
   10     3      > FE_RESET_R                                       $8      !1, ->16
          4    > > FE_FETCH_R                                       ~9      $8, !3, ->16
          5    >   ASSIGN                                                   !4, ~9
   11     6        FETCH_THIS                                       ~11     
          7        FETCH_CLASS                                   0  $12     ~11
          8        INIT_STATIC_METHOD_CALL                                  $12, 'buildInput'
          9        SEND_VAR_EX                                              !4
         10        SEND_VAR_EX                                              !3
         11        DO_FCALL                                      0  $13     
         12        ADD                                              ~14     '%5Cn', $13
         13        CONCAT                                           ~15     !2, ~14
         14        ASSIGN                                                   !2, ~15
   10    15      > JMP                                                      ->4
         16    >   FE_FREE                                                  $8
   14    17        FETCH_CONSTANT                                   ~17     'form_attributes'
         18        FETCH_LIST_R                                     $18     ~17, 0
         19        ASSIGN                                                   !5, $18
         20        FETCH_LIST_R                                     $20     ~17, 1
         21        ASSIGN                                                   !6, $20
         22        FREE                                                     ~17
   16    23        FETCH_THIS                                       ~22     
         24        FETCH_CLASS                                   0  $23     ~22
         25        INIT_STATIC_METHOD_CALL                                  $23, 'buildForm'
         26        SEND_VAR_EX                                              !2
         27        SEND_VAR_EX                                              !5
         28        SEND_VAR_EX                                              !6
         29        DO_FCALL                                      0  $24     
         30      > RETURN                                                   $24
   17    31*     > RETURN                                                   null

End of function build

Function buildinput:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/NEnf5
function name:  buildInput
number of ops:  13
compiled vars:  !0 = $id, !1 = $name
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   19     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   20     2        ROPE_INIT                                     9  ~3      '%3Cdiv+class%3D%27%27%3E%0A%09%09%09%09%09%3Clabel+for%3D%27'
   21     3        ROPE_ADD                                      1  ~3      ~3, !0
          4        ROPE_ADD                                      2  ~3      ~3, '%27+class%3D%27%27%3E'
          5        ROPE_ADD                                      3  ~3      ~3, !1
          6        ROPE_ADD                                      4  ~3      ~3, '%0A%09%09%09%09%09%09%3Cinput+type%3D%27text%27+name%3D%27'
   22     7        ROPE_ADD                                      5  ~3      ~3, !1
          8        ROPE_ADD                                      6  ~3      ~3, '%27+id%3D%27'
          9        ROPE_ADD                                      7  ~3      ~3, !0
         10        ROPE_END                                      8  ~2      ~3, '%27+class%3D%27%27%3E%0A%09%09%09%09%09%3C%2Flabel%3E%0A%09%09%09%09%3C%2Fdiv%3E'
         11      > RETURN                                                   ~2
   25    12*     > RETURN                                                   null

End of function buildinput

Function buildform:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/NEnf5
function name:  buildForm
number of ops:  12
compiled vars:  !0 = $content, !1 = $action, !2 = $method
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   27     0  E >   RECV                                             !0      
          1        RECV_INIT                                        !1      ''
          2        RECV_INIT                                        !2      'post'
   28     3        ROPE_INIT                                     7  ~4      '%3Cform+action%3D%27'
          4        ROPE_ADD                                      1  ~4      ~4, !1
          5        ROPE_ADD                                      2  ~4      ~4, '%27+class%3D%27%27+method%3D%27'
          6        ROPE_ADD                                      3  ~4      ~4, !2
          7        ROPE_ADD                                      4  ~4      ~4, '%27%3E%0A%09%09%09%09%09'
   29     8        ROPE_ADD                                      5  ~4      ~4, !0
          9        ROPE_END                                      6  ~3      ~4, '%0A%09%09%09%09%3C%2Fform%3E'
         10      > RETURN                                                   ~3
   31    11*     > RETURN                                                   null

End of function buildform

Function callback:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/NEnf5
function name:  callback
number of ops:  7
compiled vars:  !0 = $key, !1 = $value
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   33     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   34     2        INIT_FCALL_BY_NAME                                       'buildInput'
          3        SEND_VAR_EX                                              !0
          4        SEND_VAR_EX                                              !1
          5        DO_FCALL                                      0          
   35     6      > RETURN                                                   null

End of function callback

End of class FormBuilder.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
153.06 ms | 1394 KiB | 13 Q