PHP
class Security
{
public function Values ( $values )
{
if ( !is_array ( $values ) )
{
throw new exception ( ' Value is not in array. ' );
}
else
{
if ( ! $this->values )
{
foreach ( $values as $value )
{
$this->value[] = addslashes ( $value ) ;
}
}
else
{
throw new exception ( ' Value already specified. ' );
}
}
}
public function Numeric ( $value )
{
if ( ! is_int ( $value ) OR ! is_float ( $value ) )
{
throw new exception ( ' Value is not an integer or float value. ' );
}
}
public function Alpha ( $value )
{
if ( ! preg_match('/^[a-zA-Z]+$/i', $value) )
{
throw new exception ( ' Value is not alphabetic. ' );
}
}
}
Toon Meer
ja ik weet er is:
is_numeric / ctype_digit / ctype_alpha
maar gewoon een class schrijven voor de eerste keer en ja ik weet ook exceptions worden nog nergens opgevangen daar moet ik nog 1 en ander over lezen [a]