3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php class Stripper{ var $regex; var $stripped; var $decoded; var $current_encoding; var $result; function __construct(){ mb_internal_encoding('UTF-8'); //mb_regex_encoding("UTF-8"); setlocale(LC_ALL, 'de_DE@euro', 'de_DE', 'deu_deu'); } function convert($string, $targetEncoding = 'UTF-8'){ $current_encoding = mb_detect_encoding($string); if($current_encoding != $targetEncoding){ $string = mb_convert_encoding($string, $targetEncoding, mb_detect_encoding($string)); } $result = $string; return $result; } //this function returns characters, whitespace, underscores and linebreaks plus @ , and - function strip($string){ //$this->convert($string); $result = mb_ereg_replace("[^\w\s@,\-\.]*", "", $string); return $result; } //this function returns $digits of number and discards everything else function onlyNumbers($string, $digits=0){ //$this->convert($string); $result = mb_ereg_replace("[^\d]*", "", $string); if($digits > 0){ $result = substr($result, 0, $digits); } return $result; } function decode($string, $type="all"){ //$this->convert($string); if($type == "all" || $type == "strip"){ $string = stripslashes($string); } if ($type == "all" || $type == "decode"){ $string = urldecode($string); } $result = $string; return $result; } } //mb_detect_order ( mb_internal_encoding('UTF-8'); mb_http_output('UTF-8'); mb_http_input('UTF-8'); mb_language('uni'); mb_regex_encoding('UTF-8'); ob_start('mb_output_handler'); //var_dump(mb_regex_encoding()); //var_dump( mb_get_info()); $value = "Häslïchëräëÿüïöáéüúíóßñµç.,_-;()''\"\" "; //$value = $stripper->decode($value); //$value = $stripper->convert($value); echo "before strip :" . mb_detect_encoding($value) . " for $value<br />"; //$_POST[$key] = $purifier->purify($_POST[$key]); //$value = str_replace("ß","ss",$value); $stripper = new Stripper(); $value = $stripper->strip($value); echo "after strip :". mb_detect_encoding($value) . " for $value<br />"; //phpinfo();
based on nrnvp
Output for 5.4.20 - 5.6.28, 7.0.0 - 7.1.0
before strip :UTF-8 for Häslïchëräëÿüïöáéüúíóßñµç.,_-;()''"" <br />after strip :UTF-8 for H?sl?ch?r????????????????.,_- <br />
Output for hhvm-3.10.0 - 3.12.0
before strip :UTF-8 for Häslïchëräëÿüïöáéüúíóßñµç.,_-;()''"" <br />after strip :UTF-8 for H�sl�ch�r����������������.,_- <br />
Output for 5.4.0 - 5.4.19
before strip :UTF-8 for Häslïchëräëÿüïöáéüúíóßñµç.,_-;()''"" <br />after strip :UTF-8 for H?sl?ch?r????????.,_- <br />
Output for 5.1.3 - 5.3.29
before strip :UTF-8 for Häslïchëräëÿüïöáéüúíóßñµç.,_-;()''"" <br />after strip :UTF-8 for Hslchr.,_- <br />
Output for 5.0.0 - 5.0.5, 5.1.1 - 5.1.2
Strict Standards: var: Deprecated. Please use the public/private/protected modifiers in /in/rmHkq on line 4 Strict Standards: var: Deprecated. Please use the public/private/protected modifiers in /in/rmHkq on line 5 Strict Standards: var: Deprecated. Please use the public/private/protected modifiers in /in/rmHkq on line 6 Strict Standards: var: Deprecated. Please use the public/private/protected modifiers in /in/rmHkq on line 7 Strict Standards: var: Deprecated. Please use the public/private/protected modifiers in /in/rmHkq on line 8 before strip :UTF-8 for Häslïchëräëÿüïöáéüúíóßñµç.,_-;()''"" <br />after strip :UTF-8 for Hslchr.,_- <br />
Output for 5.1.0
Strict Standards: var: Deprecated. Please use the public/private/protected modifiers in /in/rmHkq on line 4 Strict Standards: var: Deprecated. Please use the public/private/protected modifiers in /in/rmHkq on line 5 Strict Standards: var: Deprecated. Please use the public/private/protected modifiers in /in/rmHkq on line 6 Strict Standards: var: Deprecated. Please use the public/private/protected modifiers in /in/rmHkq on line 7 Strict Standards: var: Deprecated. Please use the public/private/protected modifiers in /in/rmHkq on line 8 Fatal error: fatal flex scanner internal error--end of buffer missed in /in/rmHkq on line 75
Process exited with code 255.
Output for 4.3.4 - 4.4.9
before strip :UTF-8 for Häslïchëräëÿüïöáéüúíóßñµç.,_-;()''"" <br />after strip :UTF-8 for Häslïchëräëÿüïöáéüúíóßñµç.,_- <br />
Output for 4.3.2 - 4.3.3
Fatal error: Call to undefined function: mb_regex_encoding() in /in/rmHkq on line 57
Process exited with code 255.
Output for 4.3.0 - 4.3.1
Fatal error: Call to undefined function: mb_regex_encoding() in /in/rmHkq on line 57