3v4l.org

run code in 300+ PHP versions simultaneously
<?php Class App_Messages{ protected static $ANSI_CODES = array( "Reset" => 0, "Bold" => 1, "Italic" => 3, "Underline" => 4, "Blink" => 5, "Inverse" => 7, "Hidden" => 8, "BLK" => 30, "RED" => 31, "GRN" => 32, "YEL" => 33, "BLU" => 34, "PUR" => 35, "CYN" => 36, "WHT" => 37, "BLK_bg" => 40, "RED_bg" => 41, "GRN_bg" => 42, "YEL_bg" => 43, "BLU_bg" => 44, "PUR_bg" => 45, "CYN_bg" => 46, "WHT_bg" => 47 ); public static function printToScreen($message,$format = NULL) { echo EOL.self::set($message,$format).EOL; } public static function set($str, $color = NULL) { if (!isset($color)) { return $str; } $color_attrs = explode("+", $color); $ansi_str = ""; foreach ($color_attrs as $attr) { $ansi_str .= "\033[" . self::$ANSI_CODES[$attr] . "m"; } $ansi_str .= $str . "\033[" . self::$ANSI_CODES["Reset"] . "m"; return $ansi_str; } public static function replace($full_text, $search_regexp, $color) { $new_text = preg_replace_callback( "/($search_regexp)/", function ($matches) use ($color) { return App_Messages::set($matches[1], $color); }, $full_text ); return is_null($new_text) ? $full_text : $new_text; } } App_Messages::printToScreen("HELLO","BLU+Bold");
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/QYEp7
function name:  (null)
number of ops:  5
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   70     0  E >   INIT_STATIC_METHOD_CALL                                  'App_Messages', 'printToScreen'
          1        SEND_VAL                                                 'HELLO'
          2        SEND_VAL                                                 'BLU%2BBold'
          3        DO_FCALL                                      0          
          4      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2FQYEp7%3A61%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/QYEp7
function name:  {closure}
number of ops:  9
compiled vars:  !0 = $matches, !1 = $color
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   61     0  E >   RECV                                             !0      
          1        BIND_STATIC                                              !1
   62     2        INIT_STATIC_METHOD_CALL                                  'App_Messages', 'set'
          3        FETCH_DIM_R                                      ~2      !0, 1
          4        SEND_VAL                                                 ~2
          5        SEND_VAR                                                 !1
          6        DO_FCALL                                      0  $3      
          7      > RETURN                                                   $3
   63     8*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FQYEp7%3A61%240

Class App_Messages:
Function printtoscreen:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/QYEp7
function name:  printToScreen
number of ops:  12
compiled vars:  !0 = $message, !1 = $format
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   30     0  E >   RECV                                             !0      
          1        RECV_INIT                                        !1      null
   32     2        FETCH_CONSTANT                                   ~2      'EOL'
          3        INIT_STATIC_METHOD_CALL                                  'set'
          4        SEND_VAR_EX                                              !0
          5        SEND_VAR_EX                                              !1
          6        DO_FCALL                                      0  $3      
          7        CONCAT                                           ~4      ~2, $3
          8        FETCH_CONSTANT                                   ~5      'EOL'
          9        CONCAT                                           ~6      ~4, ~5
         10        ECHO                                                     ~6
   34    11      > RETURN                                                   null

End of function printtoscreen

Function set:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 5, Position 2 = 6
Branch analysis from position: 5
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 6
2 jumps found. (Code = 77) Position 1 = 13, Position 2 = 20
Branch analysis from position: 13
2 jumps found. (Code = 78) Position 1 = 14, Position 2 = 20
Branch analysis from position: 14
1 jumps found. (Code = 42) Position 1 = 13
Branch analysis from position: 13
Branch analysis from position: 20
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 20
filename:       /in/QYEp7
function name:  set
number of ops:  29
compiled vars:  !0 = $str, !1 = $color, !2 = $color_attrs, !3 = $ansi_str, !4 = $attr
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   36     0  E >   RECV                                             !0      
          1        RECV_INIT                                        !1      null
   38     2        ISSET_ISEMPTY_CV                                 ~5      !1
          3        BOOL_NOT                                         ~6      ~5
          4      > JMPZ                                                     ~6, ->6
   40     5    > > RETURN                                                   !0
   43     6    >   INIT_FCALL                                               'explode'
          7        SEND_VAL                                                 '%2B'
          8        SEND_VAR                                                 !1
          9        DO_ICALL                                         $7      
         10        ASSIGN                                                   !2, $7
   45    11        ASSIGN                                                   !3, ''
   47    12      > FE_RESET_R                                       $10     !2, ->20
         13    > > FE_FETCH_R                                               $10, !4, ->20
   49    14    >   FETCH_STATIC_PROP_R          global lock         ~11     'ANSI_CODES'
         15        FETCH_DIM_R                                      ~12     ~11, !4
         16        CONCAT                                           ~13     '%1B%5B', ~12
         17        CONCAT                                           ~14     ~13, 'm'
         18        ASSIGN_OP                                     8          !3, ~14
   47    19      > JMP                                                      ->13
         20    >   FE_FREE                                                  $10
   52    21        CONCAT                                           ~16     !0, '%1B%5B'
         22        FETCH_STATIC_PROP_R          unknown             ~17     'ANSI_CODES'
         23        FETCH_DIM_R                                      ~18     ~17, 'Reset'
         24        CONCAT                                           ~19     ~16, ~18
         25        CONCAT                                           ~20     ~19, 'm'
         26        ASSIGN_OP                                     8          !3, ~20
   54    27      > RETURN                                                   !3
   55    28*     > RETURN                                                   null

End of function set

Function replace:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 16, Position 2 = 18
Branch analysis from position: 16
1 jumps found. (Code = 42) Position 1 = 19
Branch analysis from position: 19
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 18
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/QYEp7
function name:  replace
number of ops:  21
compiled vars:  !0 = $full_text, !1 = $search_regexp, !2 = $color, !3 = $new_text
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   57     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV                                             !2      
   59     3        INIT_FCALL                                               'preg_replace_callback'
   60     4        ROPE_INIT                                     3  ~5      '%2F%28'
          5        ROPE_ADD                                      1  ~5      ~5, !1
          6        ROPE_END                                      2  ~4      ~5, '%29%2F'
          7        SEND_VAL                                                 ~4
   61     8        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FQYEp7%3A61%240'
          9        BIND_LEXICAL                                             ~7, !2
   63    10        SEND_VAL                                                 ~7
   64    11        SEND_VAR                                                 !0
         12        DO_ICALL                                         $8      
   59    13        ASSIGN                                                   !3, $8
   66    14        TYPE_CHECK                                    2          !3
         15      > JMPZ                                                     ~10, ->18
         16    >   QM_ASSIGN                                        ~11     !0
         17      > JMP                                                      ->19
         18    >   QM_ASSIGN                                        ~11     !3
         19    > > RETURN                                                   ~11
   67    20*     > RETURN                                                   null

End of function replace

End of class App_Messages.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
151.88 ms | 950 KiB | 18 Q