3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Sanitizer { public function sanitizeSingle(&$string) { if (function_exists("get_magic_quotes_gpc") && get_magic_quotes_gpc()) { $string = stripslashes($string); } $string = trim(htmlspecialchars($string, ENT_QUOTES)); } public function sanitize($data) { if (is_array($data)) { array_walk_recursive($data, [$this, 'sanitizeSingle']); } else { $this->sanitizeSingle($data); } return $data; } } $array = ['one' => ['a ', ' b ', ' c'], 'two' => " <a href='test'>Test</a>"]; $string = ' another "test"'; $sanitizer = new Sanitizer(); var_export($sanitizer->sanitize($array)); echo "\n---\n"; var_export($sanitizer->sanitize($string));
Output for git.master, git.master_jit, rfc.property-hooks
array ( 'one' => array ( 0 => 'a', 1 => 'b', 2 => 'c', ), 'two' => '&lt;a href=&#039;test&#039;&gt;Test&lt;/a&gt;', ) --- 'another &quot;test&quot;'

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
27.05 ms | 405 KiB | 5 Q