3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Phrase { public function __construct($text, $arguments = array()) { $this->_text = (string)$text; $this->_arguments = $arguments; } public function __toString() { return $this->render($this->_text, $this->_arguments); } public function render($text, $arguments) { if ($arguments) { $placeholders = array(); for ($i = 1, $size = count($arguments); $i <= $size; $i++) { $placeholders[] = "%$i"; } $text = str_replace($placeholders, $arguments, $text); } return $text; } } function __(){ $argc = func_get_args(); return new Phrase(array_shift($argc), $argc); } try { throw new Exception(__('one %1 one' , 1111)); } catch (Exception $e) { var_dump(strpos($e->getMessage(), 'one %1 one')); } $a = array(__('saadfdsa'), __('sdfgsda sa%1 ', 4), __('sdgsa gsag sg %1 gas g%2 w4', 1111,222)); echo implode($a);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 108) Position 1 = -2
Found catch point at position: 10
Branch analysis from position: 10
2 jumps found. (Code = 107) Position 1 = 11, Position 2 = -2
Branch analysis from position: 11
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/LiIJF
function name:  (null)
number of ops:  41
compiled vars:  !0 = $e, !1 = $a
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   DECLARE_CLASS                                            'phrase'
   41     1        NEW                                              $2      'Exception'
          2        INIT_FCALL                                               '__'
          3        SEND_VAL                                                 'one+%251+one'
          4        SEND_VAL                                                 1111
          5        DO_FCALL                                      0  $3      
          6        SEND_VAR_NO_REF_EX                                       $3
          7        DO_FCALL                                      0          
          8      > THROW                                         0          $2
          9*       JMP                                                      ->20
   42    10  E > > CATCH                                       last         'Exception'
   43    11    >   INIT_FCALL                                               'var_dump'
         12        INIT_FCALL                                               'strpos'
         13        INIT_METHOD_CALL                                         !0, 'getMessage'
         14        DO_FCALL                                      0  $5      
         15        SEND_VAR                                                 $5
         16        SEND_VAL                                                 'one+%251+one'
         17        DO_ICALL                                         $6      
         18        SEND_VAR                                                 $6
         19        DO_ICALL                                                 
   46    20        INIT_FCALL                                               '__'
         21        SEND_VAL                                                 'saadfdsa'
         22        DO_FCALL                                      0  $8      
         23        INIT_ARRAY                                       ~9      $8
         24        INIT_FCALL                                               '__'
         25        SEND_VAL                                                 'sdfgsda+sa%251+'
         26        SEND_VAL                                                 4
         27        DO_FCALL                                      0  $10     
         28        ADD_ARRAY_ELEMENT                                ~9      $10
         29        INIT_FCALL                                               '__'
         30        SEND_VAL                                                 'sdgsa+gsag+sg+%251+gas+g%252+w4'
         31        SEND_VAL                                                 1111
         32        SEND_VAL                                                 222
         33        DO_FCALL                                      0  $11     
         34        ADD_ARRAY_ELEMENT                                ~9      $11
         35        ASSIGN                                                   !1, ~9
   47    36        INIT_FCALL                                               'implode'
         37        SEND_VAR                                                 !1
         38        DO_ICALL                                         $13     
         39        ECHO                                                     $13
         40      > RETURN                                                   1

Function __:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/LiIJF
function name:  __
number of ops:  11
compiled vars:  !0 = $argc
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   32     0  E >   FUNC_GET_ARGS                                    ~1      
          1        ASSIGN                                                   !0, ~1
   34     2        NEW                                              $3      'Phrase'
          3        INIT_FCALL                                               'array_shift'
          4        SEND_REF                                                 !0
          5        DO_ICALL                                         $4      
          6        SEND_VAR_NO_REF_EX                                       $4
          7        SEND_VAR_EX                                              !0
          8        DO_FCALL                                      0          
          9      > RETURN                                                   $3
   36    10*     > RETURN                                                   null

End of function __

Class Phrase:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/LiIJF
function name:  __construct
number of ops:  8
compiled vars:  !0 = $text, !1 = $arguments
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   RECV                                             !0      
          1        RECV_INIT                                        !1      <array>
    7     2        CAST                                          6  ~3      !0
          3        ASSIGN_OBJ                                               '_text'
          4        OP_DATA                                                  ~3
    8     5        ASSIGN_OBJ                                               '_arguments'
          6        OP_DATA                                                  !1
    9     7      > RETURN                                                   null

End of function __construct

Function __tostring:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/LiIJF
function name:  __toString
number of ops:  12
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   14     0  E >   INIT_METHOD_CALL                                         'render'
          1        CHECK_FUNC_ARG                                           
          2        FETCH_OBJ_FUNC_ARG                               $0      '_text'
          3        SEND_FUNC_ARG                                            $0
          4        CHECK_FUNC_ARG                                           
          5        FETCH_OBJ_FUNC_ARG                               $1      '_arguments'
          6        SEND_FUNC_ARG                                            $1
          7        DO_FCALL                                      0  $2      
          8        VERIFY_RETURN_TYPE                                       $2
          9      > RETURN                                                   $2
   16    10*       VERIFY_RETURN_TYPE                                       
         11*     > RETURN                                                   null

End of function __tostring

Function render:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 3, Position 2 = 21
Branch analysis from position: 3
1 jumps found. (Code = 42) Position 1 = 13
Branch analysis from position: 13
2 jumps found. (Code = 44) Position 1 = 15, Position 2 = 8
Branch analysis from position: 15
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 8
2 jumps found. (Code = 44) Position 1 = 15, Position 2 = 8
Branch analysis from position: 15
Branch analysis from position: 8
Branch analysis from position: 21
filename:       /in/LiIJF
function name:  render
number of ops:  23
compiled vars:  !0 = $text, !1 = $arguments, !2 = $placeholders, !3 = $i, !4 = $size
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   17     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   19     2      > JMPZ                                                     !1, ->21
   20     3    >   ASSIGN                                                   !2, <array>
   21     4        ASSIGN                                                   !3, 1
          5        COUNT                                            ~7      !1
          6        ASSIGN                                                   !4, ~7
          7      > JMP                                                      ->13
   22     8    >   NOP                                                      
          9        FAST_CONCAT                                      ~10     '%25', !3
         10        ASSIGN_DIM                                               !2
         11        OP_DATA                                                  ~10
   21    12        PRE_INC                                                  !3
         13    >   IS_SMALLER_OR_EQUAL                                      !3, !4
         14      > JMPNZ                                                    ~12, ->8
   24    15    >   INIT_FCALL                                               'str_replace'
         16        SEND_VAR                                                 !2
         17        SEND_VAR                                                 !1
         18        SEND_VAR                                                 !0
         19        DO_ICALL                                         $13     
         20        ASSIGN                                                   !0, $13
   26    21    > > RETURN                                                   !0
   27    22*     > RETURN                                                   null

End of function render

End of class Phrase.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
167.61 ms | 1398 KiB | 27 Q