understanding a function .

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
gautamz07
Forum Contributor
Posts: 331
Joined: Wed May 14, 2014 12:18 pm

understanding a function .

Post 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.
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: understanding a function .

Post 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.
Post Reply