3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php abstract class Filter { abstract public static function check($value, array $options = array()); } final class IntFilter extends Filter { public static function check($value, array $options = array()) { return $value; } } final class StringFilter extends Filter { public static function check($value, array $options = array()) { // Trim if (false !== ($options['trim'] ?? true)) { $value = trim($value); } $length = mb_strlen($value, '8bit'); // Empty if (false === ($options['empty'] ?? true)) { if (0 === $length) { throw new LengthException('chaine vide !'); } } // Min & max length if (isset($options['max'])) { $maxLength = IntFilter::check($options['max'], ['min' => 1]); if ($length > $maxLength) { throw new LengthException('trop long !'); } } if (isset($options['min'])) { $minLength = IntFilter::check($options['min'], ['min' => 1]); if ($length > $minLength) { throw new LengthException('trop court !'); } } return $value; } } var_dump(StringFilter::check(' test ', ['min' => 5]));
based on mPAs5
Output for hhvm-3.15.4, 7.0.0 - 7.3.0rc3
string(4) "test"
Output for 5.6.0 - 5.6.30
Strict Standards: Static function Filter::check() should not be abstract in /in/VEGDi on line 5 Parse error: syntax error, unexpected '?' in /in/VEGDi on line 21
Process exited with code 255.