3v4l.org

run code in 300+ PHP versions simultaneously
<?php // $base = 'test image with Ümlaäute und spaäe.jpg'; $nameEncodedFromGWT = 'test%20image%20with%20U%CC%88mlaa%CC%88ute%20und%20spaa%CC%88e.jpg'; $nameEncodedFromPHP = 'test%20image%20with%20%C3%9Cmla%C3%A4ute%20und%20spa%C3%A4e.jpg'; // this is encoded with urlencode() / rawurlencode() // using rawurldecode $nameDecodedFromGWTRaw = rawurldecode($nameEncodedFromGWT); $nameDecodedFromPHPRaw = rawurldecode($nameEncodedFromPHP); // using urldecode $nameDecodedFromGWTSimple = urldecode($nameEncodedFromGWT); $nameDecodedFromPHPSimple = urldecode($nameEncodedFromPHP); echo 'Name from GWT: ' . $nameEncodedFromGWT . PHP_EOL . 'Decoded using rawurldecode(): ' . $nameDecodedFromGWTRaw . PHP_EOL . 'Decoded using urldecode(): ' . $nameDecodedFromGWTSimple . PHP_EOL . 'String length for rawurldecode(): ' . strlen($nameDecodedFromGWTRaw) . PHP_EOL . 'String length for urldeocde(): ' . strlen($nameDecodedFromGWTSimple) . PHP_EOL . 'Cleaned name for rawurldecode(): ' . cleanImageName($nameDecodedFromGWTRaw) . PHP_EOL . 'Cleaned name for urldecode(): ' . cleanImageName($nameDecodedFromGWTSimple); echo PHP_EOL . '===============================================' . PHP_EOL; echo 'Name from PHP: ' . $nameEncodedFromPHP . PHP_EOL . 'Decoded using rawurldecode(): ' . $nameDecodedFromPHPRaw . PHP_EOL . 'Decoded using urldecode(): ' . $nameDecodedFromPHPSimple . PHP_EOL . 'String length for rawurldecode(): ' . strlen($nameDecodedFromPHPRaw) . PHP_EOL . 'String length for urldecode(): ' . strlen($nameDecodedFromPHPSimple) . PHP_EOL . 'Cleaned name for rawurldecode(): ' . cleanImageName($nameDecodedFromPHPRaw) . PHP_EOL . 'Cleaned name for urldecode(): ' . cleanImageName($nameDecodedFromPHPSimple); /** * Uses preg_replace to replace german umlauts */ function cleanImageName($name) { $clean = preg_replace( array( '/\|/', '/[äÄ]/u', '/[öÖ]/u', '/[üÜ]/u', '/ß/', '/([a-zA-Z0-9]+)/i', '/ - /','/ /','/-/','/&/', '/[á|à|À|Á]/u', '/[é|è|É|È]/u', '/[_\x7c-\xff\$\%\=\?\@\(\)§!\|`´\*#;,:\.<>\/"\'#\t\r\n]/' ), array( ' ', 'ae', 'oe', 'ue', 'ss', '$1', ' ', ' ', ' ', 'und', 'a', 'e', ' ', ), $name); return str_replace(' ', '-', $clean); } ?>
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/T1g1O
function name:  (null)
number of ops:  76
compiled vars:  !0 = $nameEncodedFromGWT, !1 = $nameEncodedFromPHP, !2 = $nameDecodedFromGWTRaw, !3 = $nameDecodedFromPHPRaw, !4 = $nameDecodedFromGWTSimple, !5 = $nameDecodedFromPHPSimple
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   ASSIGN                                                   !0, 'test%2520image%2520with%2520U%25CC%2588mlaa%25CC%2588ute%2520und%2520spaa%25CC%2588e.jpg'
    6     1        ASSIGN                                                   !1, 'test%2520image%2520with%2520%25C3%259Cmla%25C3%25A4ute%2520und%2520spa%25C3%25A4e.jpg'
    9     2        INIT_FCALL                                               'rawurldecode'
          3        SEND_VAR                                                 !0
          4        DO_ICALL                                         $8      
          5        ASSIGN                                                   !2, $8
   10     6        INIT_FCALL                                               'rawurldecode'
          7        SEND_VAR                                                 !1
          8        DO_ICALL                                         $10     
          9        ASSIGN                                                   !3, $10
   13    10        INIT_FCALL                                               'urldecode'
         11        SEND_VAR                                                 !0
         12        DO_ICALL                                         $12     
         13        ASSIGN                                                   !4, $12
   14    14        INIT_FCALL                                               'urldecode'
         15        SEND_VAR                                                 !1
         16        DO_ICALL                                         $14     
         17        ASSIGN                                                   !5, $14
   17    18        CONCAT                                           ~16     'Name+from+GWT%3A+', !0
         19        CONCAT                                           ~17     ~16, '%0A'
   18    20        CONCAT                                           ~18     ~17, 'Decoded+using+rawurldecode%28%29%3A+'
         21        CONCAT                                           ~19     ~18, !2
         22        CONCAT                                           ~20     ~19, '%0A'
   19    23        CONCAT                                           ~21     ~20, 'Decoded+using+urldecode%28%29%3A+'
         24        CONCAT                                           ~22     ~21, !4
         25        CONCAT                                           ~23     ~22, '%0A'
   20    26        CONCAT                                           ~24     ~23, 'String+length+for+rawurldecode%28%29%3A+'
         27        STRLEN                                           ~25     !2
         28        CONCAT                                           ~26     ~24, ~25
         29        CONCAT                                           ~27     ~26, '%0A'
   21    30        CONCAT                                           ~28     ~27, 'String+length+for+urldeocde%28%29%3A+'
         31        STRLEN                                           ~29     !4
         32        CONCAT                                           ~30     ~28, ~29
         33        CONCAT                                           ~31     ~30, '%0A'
   22    34        CONCAT                                           ~32     ~31, 'Cleaned+name+for+rawurldecode%28%29%3A+'
         35        INIT_FCALL_BY_NAME                                       'cleanImageName'
         36        SEND_VAR_EX                                              !2
         37        DO_FCALL                                      0  $33     
         38        CONCAT                                           ~34     ~32, $33
         39        CONCAT                                           ~35     ~34, '%0A'
   23    40        CONCAT                                           ~36     ~35, 'Cleaned+name+for+urldecode%28%29%3A+'
         41        INIT_FCALL_BY_NAME                                       'cleanImageName'
         42        SEND_VAR_EX                                              !4
         43        DO_FCALL                                      0  $37     
         44        CONCAT                                           ~38     ~36, $37
         45        ECHO                                                     ~38
   25    46        ECHO                                                     '%0A%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%0A'
   27    47        CONCAT                                           ~39     'Name+from+PHP%3A+', !1
         48        CONCAT                                           ~40     ~39, '%0A'
   28    49        CONCAT                                           ~41     ~40, 'Decoded+using+rawurldecode%28%29%3A+'
         50        CONCAT                                           ~42     ~41, !3
         51        CONCAT                                           ~43     ~42, '%0A'
   29    52        CONCAT                                           ~44     ~43, 'Decoded+using+urldecode%28%29%3A+'
         53        CONCAT                                           ~45     ~44, !5
         54        CONCAT                                           ~46     ~45, '%0A'
   30    55        CONCAT                                           ~47     ~46, 'String+length+for+rawurldecode%28%29%3A+'
         56        STRLEN                                           ~48     !3
         57        CONCAT                                           ~49     ~47, ~48
         58        CONCAT                                           ~50     ~49, '%0A'
   31    59        CONCAT                                           ~51     ~50, 'String+length+for+urldecode%28%29%3A+'
         60        STRLEN                                           ~52     !5
         61        CONCAT                                           ~53     ~51, ~52
         62        CONCAT                                           ~54     ~53, '%0A'
   32    63        CONCAT                                           ~55     ~54, 'Cleaned+name+for+rawurldecode%28%29%3A+'
         64        INIT_FCALL_BY_NAME                                       'cleanImageName'
         65        SEND_VAR_EX                                              !3
         66        DO_FCALL                                      0  $56     
         67        CONCAT                                           ~57     ~55, $56
         68        CONCAT                                           ~58     ~57, '%0A'
   33    69        CONCAT                                           ~59     ~58, 'Cleaned+name+for+urldecode%28%29%3A+'
         70        INIT_FCALL_BY_NAME                                       'cleanImageName'
         71        SEND_VAR_EX                                              !5
         72        DO_FCALL                                      0  $60     
         73        CONCAT                                           ~61     ~59, $60
         74        ECHO                                                     ~61
   74    75      > RETURN                                                   1

Function cleanimagename:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/T1g1O
function name:  cleanImageName
number of ops:  14
compiled vars:  !0 = $name, !1 = $clean
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   39     0  E >   RECV                                             !0      
   41     1        INIT_FCALL                                               'preg_replace'
   43     2        SEND_VAL                                                 <array>
   55     3        SEND_VAL                                                 <array>
   69     4        SEND_VAR                                                 !0
          5        DO_ICALL                                         $2      
   41     6        ASSIGN                                                   !1, $2
   71     7        INIT_FCALL                                               'str_replace'
          8        SEND_VAL                                                 '+'
          9        SEND_VAL                                                 '-'
         10        SEND_VAR                                                 !1
         11        DO_ICALL                                         $4      
         12      > RETURN                                                   $4
   72    13*     > RETURN                                                   null

End of function cleanimagename

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
166.1 ms | 1404 KiB | 21 Q