3v4l.org

run code in 300+ PHP versions simultaneously
<?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 git.master, git.master_jit, rfc.property-hooks

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:
38.15 ms | 401 KiB | 8 Q