3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?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(): ' . $nameDecodedFromPHPRaw . PHP_EOL . 'String length for urldecode(): ' . $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); } ?>
based on NeplW
Output for 4.3.10 - 4.4.9, 5.0.2 - 7.2.0
Name from GWT: test%20image%20with%20U%CC%88mlaa%CC%88ute%20und%20spaa%CC%88e.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(): 44 String length for urldeocde(): 44 Cleaned name for rawurldecode(): test-image-with-U--mlaa--ute-und-spaa--e-jpg Cleaned name for urldecode(): test-image-with-U--mlaa--ute-und-spaa--e-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(): test image with Ümlaäute und spaäe.jpg String length for urldecode(): test image with Ümlaäute und spaäe.jpg 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/N0vp0 on line 17 Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/N0vp0 on line 18 Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/N0vp0 on line 19 Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/N0vp0 on line 20 Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/N0vp0 on line 21 Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/N0vp0 on line 22 Name from GWT: test%20image%20with%20U%CC%88mlaa%CC%88ute%20und%20spaa%CC%88e.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(): 44PHP_EOLString length for urldeocde(): 44PHP_EOLCleaned name for rawurldecode(): test-image-with-U--mlaa--ute-und-spaa--e-jpgPHP_EOLCleaned name for urldecode(): test-image-with-U--mlaa--ute-und-spaa--e-jpg Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/N0vp0 on line 25 Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/N0vp0 on line 25 PHP_EOL===============================================PHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/N0vp0 on line 27 Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/N0vp0 on line 28 Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/N0vp0 on line 29 Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/N0vp0 on line 30 Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/N0vp0 on line 31 Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/N0vp0 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(): test image with Ümlaäute und spaäe.jpgPHP_EOLString length for urldecode(): test image with Ümlaäute und spaäe.jpgPHP_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/N0vp0 on line 17 Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/N0vp0 on line 18 Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/N0vp0 on line 19 Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/N0vp0 on line 20 Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/N0vp0 on line 21 Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/N0vp0 on line 22 Name from GWT: test%20image%20with%20U%CC%88mlaa%CC%88ute%20und%20spaa%CC%88e.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(): 44PHP_EOLString length for urldeocde(): 44PHP_EOLCleaned name for rawurldecode(): test-image-with-U-emlaa-eute-und-spaa-ee-jpgPHP_EOLCleaned name for urldecode(): test-image-with-U-emlaa-eute-und-spaa-ee-jpg Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/N0vp0 on line 25 Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/N0vp0 on line 25 PHP_EOL===============================================PHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/N0vp0 on line 27 Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/N0vp0 on line 28 Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/N0vp0 on line 29 Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/N0vp0 on line 30 Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/N0vp0 on line 31 Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/N0vp0 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(): test image with Ümlaäute und spaäe.jpgPHP_EOLString length for urldecode(): test image with Ümlaäute und spaäe.jpgPHP_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