Page 1 of 1

understanding a function .

Posted: Mon Dec 08, 2014 2:09 am
by gautamz07
i have this belwo function

Code: Select all

public function __construct($required = array(), $inputType = 'post')
{
if (!function_exists('filter_list')) {
throw new Exception('The Pos_Validator class requires the Filter 
Functions in >= PHP 5.2 or PECL.');
}
if (!is_null($required) && !is_array($required)) {
throw new Exception('The names of required fields must be an array,
even if only one field is required.');
}
$this->_required = $required;
$this->setInputType($inputType);
}
what are the below two lines of code really doing ??

Code: Select all

if (!function_exists('filter_list')) {
throw new Exception('The Pos_Validator class requires the Filter
Functions in >= PHP 5.2 or PECL.');
}
if (!is_null($required) && !is_array($required)) {
throw new Exception('The names of required fields must be an array,
even if only one field is required.');
}
Thanks.

Gautam.

Re: understanding a function .

Posted: Mon Dec 08, 2014 4:23 am
by requinix
1. If the function "filter_list" does not exist then throw the exception. That would happen if the filter functions in PHP 5.2+ or in PECL are not installed.
2. If $required is not null and it is not an array then throw the exception.

Or you could, you know, read the error messages and use the online documentation.