3v4l.org

run code in 500+ PHP versions simultaneously
<?php function SilentGhost($z){ $z = strtolower($z); $z = preg_replace('/[^a-z0-9 -]+/', '', $z); $z = str_replace(' ', '-', $z); return trim($z, '-'); } function mario($z) { return strtolower(trim(preg_replace("/[^\w]+/", "-", $z), "-")); } function Rooneyl($string) { $new_string = preg_replace("/[^a-zA-Z0-9\s]/", "", $string); $url = preg_replace('/\s/', '-', $new_string); $new_url = urlencode($url); return $new_url; } function AbhishekGoel($string) { $string = str_replace(' ', '-', $string); // Replaces all spaces with hyphens. $string = preg_replace('/[^A-Za-z0-9\-]/', '', $string); // Removes special chars. return preg_replace('/-+/', '-', $string); // Replaces multiple hyphens with single one. } function HelloHack($data) { $data = trim($data); $data = stripslashes($data); $data = htmlspecialchars($data); return $data; } function DenisMatafonov($str) { $withSpecCharacters = htmlspecialchars($str); $splitted_str = str_split($str); $result = ''; foreach ($splitted_str as $letter){ if (strpos($withSpecCharacters, $letter) !== false) { $result .= $letter; } } return $result; } function AdeelRazaAzeemi($str) { $str = str_replace(' ', '-', $str); $str = preg_replace('/[^\x20-\x7E]/', '', $str); return $str; } function mickmackusa($string) { return trim(preg_replace('/[^a-z0-9]+/', '-', strtolower($string)), '-'); } $strings = [ 'This, is - - the URL!', 'Mork & Mindy', 'What the_underscore ?!?' ]; $funcs = ['SilentGhost', 'mario', 'Rooneyl', 'AbhishekGoel', 'HelloHack', 'DenisMatafonov', 'AdeelRazaAzeemi', 'mickmackusa']; foreach ($strings as $string) { echo "\n---\n" . var_export($string, true) . "\tinput\n"; foreach ($funcs as $func) { echo var_export($func($string), true) . "\t$func\n"; } }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 3, Position 2 = 28
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 28
Branch analysis from position: 4
2 jumps found. (Code = 77) Position 1 = 12, Position 2 = 26
Branch analysis from position: 12
2 jumps found. (Code = 78) Position 1 = 13, Position 2 = 26
Branch analysis from position: 13
1 jumps found. (Code = 42) Position 1 = 12
Branch analysis from position: 12
Branch analysis from position: 26
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 26
Branch analysis from position: 28
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 28
filename:       /in/brB6T
function name:  (null)
number of ops:  30
compiled vars:  !0 = $strings, !1 = $funcs, !2 = $string, !3 = $func
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   56     0  E >   ASSIGN                                                       !0, <array>
   62     1        ASSIGN                                                       !1, <array>
   64     2      > FE_RESET_R                                           $6      !0, ->28
          3    > > FE_FETCH_R                                                   $6, !2, ->28
   65     4    >   INIT_FCALL                                                   'var_export'
          5        SEND_VAR                                                     !2
          6        SEND_VAL                                                     <true>
          7        DO_ICALL                                             $7      
          8        CONCAT                                               ~8      '%0A---%0A', $7
          9        CONCAT                                               ~9      ~8, '%09input%0A'
         10        ECHO                                                         ~9
   66    11      > FE_RESET_R                                           $10     !1, ->26
         12    > > FE_FETCH_R                                                   $10, !3, ->26
   67    13    >   INIT_FCALL                                                   'var_export'
         14        INIT_DYNAMIC_CALL                                            !3
         15        SEND_VAR_EX                                                  !2
         16        DO_FCALL                                          0  $11     
         17        SEND_VAR                                                     $11
         18        SEND_VAL                                                     <true>
         19        DO_ICALL                                             $12     
         20        ROPE_INIT                                         3  ~14     '%09'
         21        ROPE_ADD                                          1  ~14     ~14, !3
         22        ROPE_END                                          2  ~13     ~14, '%0A'
         23        CONCAT                                               ~16     $12, ~13
         24        ECHO                                                         ~16
   66    25      > JMP                                                          ->12
         26    >   FE_FREE                                                      $10
   64    27      > JMP                                                          ->3
         28    >   FE_FREE                                                      $6
   69    29      > RETURN                                                       1

Function silentghost:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/brB6T
function name:  SilentGhost
number of ops:  14
compiled vars:  !0 = $z
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   RECV                                                 !0      
    4     1        INIT_FCALL                                                   'strtolower'
          2        SEND_VAR                                                     !0
          3        DO_ICALL                                             $1      
          4        ASSIGN                                                       !0, $1
    5     5        FRAMELESS_ICALL_3                preg_replace        ~3      '%2F%5B%5Ea-z0-9+-%5D%2B%2F', ''
          6        OP_DATA                                                      !0
          7        ASSIGN                                                       !0, ~3
    6     8        FRAMELESS_ICALL_3                str_replace         ~5      '+', '-'
          9        OP_DATA                                                      !0
         10        ASSIGN                                                       !0, ~5
    7    11        FRAMELESS_ICALL_2                trim                ~7      !0, '-'
         12      > RETURN                                                       ~7
    8    13*     > RETURN                                                       null

End of function silentghost

Function mario:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/brB6T
function name:  mario
number of ops:  9
compiled vars:  !0 = $z
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   10     0  E >   RECV                                                 !0      
   11     1        INIT_FCALL                                                   'strtolower'
          2        FRAMELESS_ICALL_3                preg_replace        ~1      '%2F%5B%5E%5Cw%5D%2B%2F', '-'
          3        OP_DATA                                                      !0
          4        FRAMELESS_ICALL_2                trim                ~2      ~1, '-'
          5        SEND_VAL                                                     ~2
          6        DO_ICALL                                             $3      
          7      > RETURN                                                       $3
   12     8*     > RETURN                                                       null

End of function mario

Function rooneyl:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/brB6T
function name:  Rooneyl
number of ops:  13
compiled vars:  !0 = $string, !1 = $new_string, !2 = $url, !3 = $new_url
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   14     0  E >   RECV                                                 !0      
   15     1        FRAMELESS_ICALL_3                preg_replace        ~4      '%2F%5B%5Ea-zA-Z0-9%5Cs%5D%2F', ''
          2        OP_DATA                                                      !0
          3        ASSIGN                                                       !1, ~4
   16     4        FRAMELESS_ICALL_3                preg_replace        ~6      '%2F%5Cs%2F', '-'
          5        OP_DATA                                                      !1
          6        ASSIGN                                                       !2, ~6
   17     7        INIT_FCALL                                                   'urlencode'
          8        SEND_VAR                                                     !2
          9        DO_ICALL                                             $8      
         10        ASSIGN                                                       !3, $8
   18    11      > RETURN                                                       !3
   19    12*     > RETURN                                                       null

End of function rooneyl

Function abhishekgoel:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/brB6T
function name:  AbhishekGoel
number of ops:  11
compiled vars:  !0 = $string
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   21     0  E >   RECV                                                 !0      
   22     1        FRAMELESS_ICALL_3                str_replace         ~1      '+', '-'
          2        OP_DATA                                                      !0
          3        ASSIGN                                                       !0, ~1
   23     4        FRAMELESS_ICALL_3                preg_replace        ~3      '%2F%5B%5EA-Za-z0-9%5C-%5D%2F', ''
          5        OP_DATA                                                      !0
          6        ASSIGN                                                       !0, ~3
   24     7        FRAMELESS_ICALL_3                preg_replace        ~5      '%2F-%2B%2F', '-'
          8        OP_DATA                                                      !0
          9      > RETURN                                                       ~5
   25    10*     > RETURN                                                       null

End of function abhishekgoel

Function hellohack:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/brB6T
function name:  HelloHack
number of ops:  13
compiled vars:  !0 = $data
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   27     0  E >   RECV                                                 !0      
   28     1        FRAMELESS_ICALL_1                trim                ~1      !0
          2        ASSIGN                                                       !0, ~1
   29     3        INIT_FCALL                                                   'stripslashes'
          4        SEND_VAR                                                     !0
          5        DO_ICALL                                             $3      
          6        ASSIGN                                                       !0, $3
   30     7        INIT_FCALL                                                   'htmlspecialchars'
          8        SEND_VAR                                                     !0
          9        DO_ICALL                                             $5      
         10        ASSIGN                                                       !0, $5
   31    11      > RETURN                                                       !0
   32    12*     > RETURN                                                       null

End of function hellohack

Function denismatafonov:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 11, Position 2 = 17
Branch analysis from position: 11
2 jumps found. (Code = 78) Position 1 = 12, Position 2 = 17
Branch analysis from position: 12
2 jumps found. (Code = 43) Position 1 = 15, Position 2 = 16
Branch analysis from position: 15
1 jumps found. (Code = 42) Position 1 = 11
Branch analysis from position: 11
Branch analysis from position: 16
Branch analysis from position: 17
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 17
filename:       /in/brB6T
function name:  DenisMatafonov
number of ops:  20
compiled vars:  !0 = $str, !1 = $withSpecCharacters, !2 = $splitted_str, !3 = $result, !4 = $letter
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   34     0  E >   RECV                                                 !0      
   35     1        INIT_FCALL                                                   'htmlspecialchars'
          2        SEND_VAR                                                     !0
          3        DO_ICALL                                             $5      
          4        ASSIGN                                                       !1, $5
   36     5        INIT_FCALL                                                   'str_split'
          6        SEND_VAR                                                     !0
          7        DO_ICALL                                             $7      
          8        ASSIGN                                                       !2, $7
   37     9        ASSIGN                                                       !3, ''
   38    10      > FE_RESET_R                                           $10     !2, ->17
         11    > > FE_FETCH_R                                                   $10, !4, ->17
   39    12    >   FRAMELESS_ICALL_2                strpos              ~11     !1, !4
         13        TYPE_CHECK                                      1018          ~11
         14      > JMPZ                                                         ~12, ->16
   40    15    >   ASSIGN_OP                                         8          !3, !4
   38    16    > > JMP                                                          ->11
         17    >   FE_FREE                                                      $10
   43    18      > RETURN                                                       !3
   44    19*     > RETURN                                                       null

End of function denismatafonov

Function adeelrazaazeemi:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/brB6T
function name:  AdeelRazaAzeemi
number of ops:  9
compiled vars:  !0 = $str
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   46     0  E >   RECV                                                 !0      
   47     1        FRAMELESS_ICALL_3                str_replace         ~1      '+', '-'
          2        OP_DATA                                                      !0
          3        ASSIGN                                                       !0, ~1
   48     4        FRAMELESS_ICALL_3                preg_replace        ~3      '%2F%5B%5E%5Cx20-%5Cx7E%5D%2F', ''
          5        OP_DATA                                                      !0
          6        ASSIGN                                                       !0, ~3
   49     7      > RETURN                                                       !0
   50     8*     > RETURN                                                       null

End of function adeelrazaazeemi

Function mickmackusa:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/brB6T
function name:  mickmackusa
number of ops:  9
compiled vars:  !0 = $string
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   52     0  E >   RECV                                                 !0      
   53     1        INIT_FCALL                                                   'strtolower'
          2        SEND_VAR                                                     !0
          3        DO_ICALL                                             $1      
          4        FRAMELESS_ICALL_3                preg_replace        ~2      '%2F%5B%5Ea-z0-9%5D%2B%2F', '-'
          5        OP_DATA                                                      $1
          6        FRAMELESS_ICALL_2                trim                ~3      ~2, '-'
          7      > RETURN                                                       ~3
   54     8*     > RETURN                                                       null

End of function mickmackusa

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
182.59 ms | 2164 KiB | 27 Q