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%u0308mlaa%u0308ute%20und%20spaa%u0308e.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); function utf8_urldecode($str) { $str = preg_replace("/%u([0-9a-f]{3,4})/i","&#x\\1;",urldecode($str)); return html_entity_decode($str,null,'UTF-8');; } /** * 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); } ?>
Output for 4.3.10 - 4.3.11, 4.4.0 - 4.4.9, 5.0.2 - 5.0.5, 5.1.0 - 5.1.6, 5.2.0 - 5.2.17, 5.3.0 - 5.3.29, 5.4.0 - 5.4.45, 5.5.24 - 5.5.35, 5.6.8 - 5.6.28, 7.0.0 - 7.0.20, 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.4, 8.3.6
Name from GWT: test%20image%20with%20U%u0308mlaa%u0308ute%20und%20spaa%u0308e.jpg Decoded using rawurldecode(): test image with U%u0308mlaa%u0308ute und spaa%u0308e.jpg Decoded using urldecode(): test image with U%u0308mlaa%u0308ute und spaa%u0308e.jpg String length for rawurldecode(): 56 String length for urldeocde(): 56 Cleaned name for rawurldecode(): test-image-with-U-u0308mlaa-u0308ute-und-spaa-u0308e-jpg Cleaned name for urldecode(): test-image-with-U-u0308mlaa-u0308ute-und-spaa-u0308e-jpg =============================================== Name from PHP: test%20image%20with%20%C3%9Cmla%C3%A4ute%20und%20spa%C3%A4e.jpg Decoded using rawurldecode(): test image with Ümlaäute und spaäe.jpg Decoded using urldecode(): test image with Ümlaäute und spaäe.jpg String length for rawurldecode(): 41 String length for urldecode(): 41 Cleaned name for rawurldecode(): test-image-with-uemlaaeute-und-spaaee-jpg Cleaned name for urldecode(): test-image-with-uemlaaeute-und-spaaee-jpg
Output for 8.3.5
Warning: PHP Startup: Unable to load dynamic library 'sodium.so' (tried: /usr/lib/php/8.3.5/modules/sodium.so (libsodium.so.23: cannot open shared object file: No such file or directory), /usr/lib/php/8.3.5/modules/sodium.so.so (/usr/lib/php/8.3.5/modules/sodium.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0 Name from GWT: test%20image%20with%20U%u0308mlaa%u0308ute%20und%20spaa%u0308e.jpg Decoded using rawurldecode(): test image with U%u0308mlaa%u0308ute und spaa%u0308e.jpg Decoded using urldecode(): test image with U%u0308mlaa%u0308ute und spaa%u0308e.jpg String length for rawurldecode(): 56 String length for urldeocde(): 56 Cleaned name for rawurldecode(): test-image-with-U-u0308mlaa-u0308ute-und-spaa-u0308e-jpg Cleaned name for urldecode(): test-image-with-U-u0308mlaa-u0308ute-und-spaa-u0308e-jpg =============================================== Name from PHP: test%20image%20with%20%C3%9Cmla%C3%A4ute%20und%20spa%C3%A4e.jpg Decoded using rawurldecode(): test image with Ümlaäute und spaäe.jpg Decoded using urldecode(): test image with Ümlaäute und spaäe.jpg String length for rawurldecode(): 41 String length for urldecode(): 41 Cleaned name for rawurldecode(): test-image-with-uemlaaeute-und-spaaee-jpg Cleaned name for urldecode(): test-image-with-uemlaaeute-und-spaaee-jpg
Output for 4.3.3 - 4.3.9, 5.0.0 - 5.0.1
Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/sSkLf on line 17 Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/sSkLf on line 18 Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/sSkLf on line 19 Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/sSkLf on line 20 Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/sSkLf on line 21 Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/sSkLf on line 22 Name from GWT: test%20image%20with%20U%u0308mlaa%u0308ute%20und%20spaa%u0308e.jpgPHP_EOLDecoded using rawurldecode(): test image with U%u0308mlaa%u0308ute und spaa%u0308e.jpgPHP_EOLDecoded using urldecode(): test image with U%u0308mlaa%u0308ute und spaa%u0308e.jpgPHP_EOLString length for rawurldecode(): 56PHP_EOLString length for urldeocde(): 56PHP_EOLCleaned name for rawurldecode(): test-image-with-U-u0308mlaa-u0308ute-und-spaa-u0308e-jpgPHP_EOLCleaned name for urldecode(): test-image-with-U-u0308mlaa-u0308ute-und-spaa-u0308e-jpg Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/sSkLf on line 25 Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/sSkLf on line 25 PHP_EOL===============================================PHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/sSkLf on line 27 Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/sSkLf on line 28 Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/sSkLf on line 29 Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/sSkLf on line 30 Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/sSkLf on line 31 Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/sSkLf on line 32 Name from PHP: test%20image%20with%20%C3%9Cmla%C3%A4ute%20und%20spa%C3%A4e.jpgPHP_EOLDecoded using rawurldecode(): test image with Ümlaäute und spaäe.jpgPHP_EOLDecoded using urldecode(): test image with Ümlaäute und spaäe.jpgPHP_EOLString length for rawurldecode(): 41PHP_EOLString length for urldecode(): 41PHP_EOLCleaned name for rawurldecode(): test-image-with-uemlaaeute-und-spaaee-jpgPHP_EOLCleaned name for urldecode(): test-image-with-uemlaaeute-und-spaaee-jpg
Output for 4.3.0 - 4.3.2
Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/sSkLf on line 17 Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/sSkLf on line 18 Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/sSkLf on line 19 Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/sSkLf on line 20 Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/sSkLf on line 21 Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/sSkLf on line 22 Name from GWT: test%20image%20with%20U%u0308mlaa%u0308ute%20und%20spaa%u0308e.jpgPHP_EOLDecoded using rawurldecode(): test image with U%u0308mlaa%u0308ute und spaa%u0308e.jpgPHP_EOLDecoded using urldecode(): test image with U%u0308mlaa%u0308ute und spaa%u0308e.jpgPHP_EOLString length for rawurldecode(): 56PHP_EOLString length for urldeocde(): 56PHP_EOLCleaned name for rawurldecode(): test-image-with-U-u0308mlaa-u0308ute-und-spaa-u0308e-jpgPHP_EOLCleaned name for urldecode(): test-image-with-U-u0308mlaa-u0308ute-und-spaa-u0308e-jpg Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/sSkLf on line 25 Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/sSkLf on line 25 PHP_EOL===============================================PHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/sSkLf on line 27 Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/sSkLf on line 28 Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/sSkLf on line 29 Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/sSkLf on line 30 Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/sSkLf on line 31 Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/sSkLf on line 32 Name from PHP: test%20image%20with%20%C3%9Cmla%C3%A4ute%20und%20spa%C3%A4e.jpgPHP_EOLDecoded using rawurldecode(): test image with Ümlaäute und spaäe.jpgPHP_EOLDecoded using urldecode(): test image with Ümlaäute und spaäe.jpgPHP_EOLString length for rawurldecode(): 41PHP_EOLString length for urldecode(): 41PHP_EOLCleaned name for rawurldecode(): test-image-with--uemla-aeute-und-spa-aee-jpgPHP_EOLCleaned name for urldecode(): test-image-with--uemla-aeute-und-spa-aee-jpg

preferences:
333.34 ms | 409 KiB | 357 Q