3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php abstract class Validate { public static $_Exceptions; public static function Run($o) { if($o->_HtmlOut == true) { $o->HtmlOutput(false); $Was_Html = true; } try { if(!is_array($o->_Fields)) throw new Exception("Os campos ainda não foram definidos."); foreach($o->_Fields as $Field) { if(is_empty($o->{$Field}) && in_array($Field, $o->_NotNull)); throw new Exception("O campo ". $Field ." da tabela ". $o->_Table ." não pode ser vazio."); switch(strtolower($o->_Meta[$Field])) { case('date') : if(!self::Date($o->{$Field}, Format::DATE)) self::$Errors[] = $Field; break; case('datetime') : if(!self::Date($o->{$Field}, Format::DATETIME)) self::$Errors[] = $Field; break; case('string') : if(!is_string($o->{$Field})) self::$Errors[] = $Field; break; case('int') : if(!is_int($o->{$Field})) if((int)($o->{$Field}) == $o->{$Field}) self::$Errors[] = $Field; break; } } } catch(Exception $e) { throw $e; } finally { if($Was_Html == true) $o->HtmlOutput(false); } if(is_array($Errors)) foreach($Errors as $Field) self::$_Exceptions[] = "Valor '". $o->{$Field} ."' para o campo ". $Field ."(".$o->_Meta[$Field].") da tabela ". $o->_Table ." é inválido"; return true; } public static function Date($data, Validate $type) { switch($type) { case(self::DATE) : if (date(DATE, strtotime($data)) == $data) return true; break; case(self::DATE_TIME) : if (date(DATE, strtotime($data)) == $data) return true; break; } return false; } public static function Throw() { $Exception = implode('<br />', self::$_Exceptions); unset(self::$_Exceptions); throw new Exception($Exception); } } ?>
Output for hhvm-3.10.0 - 3.12.0, 7.0.0 - 7.1.0
Output for 5.5.0 - 5.6.28
Parse error: syntax error, unexpected 'Throw' (T_THROW), expecting identifier (T_STRING) in /in/TYpFY on line 86
Process exited with code 255.
Output for 5.1.0 - 5.4.45
Parse error: syntax error, unexpected '{' in /in/TYpFY on line 56
Process exited with code 255.
Output for 5.0.0 - 5.0.5
Parse error: parse error, unexpected '{' in /in/TYpFY on line 56
Process exited with code 255.
Output for 4.4.2 - 4.4.9
Parse error: syntax error, unexpected T_CLASS in /in/TYpFY on line 3
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.4.1
Parse error: parse error, unexpected T_CLASS in /in/TYpFY on line 3
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error in /in/TYpFY on line 3
Process exited with code 255.