Greetings, Ashley Sheridan.
In reply to Your message dated Wednesday, October 8, 2008, 23:08:37,

>> > If you're using it to deal with possible empty input data, you'd better do 
>> > it
>> > explicitly enstead.
>> >
>> > Something like this:
>> >
>> >  if(!array_key_exists('from_year', $_POST)
>> >    || !array_key_exists('from_month', $_POST)
>> >    || !array_key_exists('from_day', $_POST)
>> >    )
>> >  {
>> >    throw new Exception('No start date given', 100);
>> >  }
>> 
>> *cough*
>> 
>> filter_input does this elegantly too ;) as does an isset() on the array index
>> 
> I'm a fan of the isset() method for POST and GET variables, as usually
> I'll still want to put something in the variables I'm assigning those
> values to, rather than the NULL which gets returned by the @ prefix.

Well, filter_input does not exist in 5.1.6, and iset() does not work correctly
with array keys in general.

<?php

$a = array ('test' => 1, 'hello' => NULL);

var_dump(isset($a['test']));            // TRUE
var_dump(isset($a['foo']));             // FALSE
var_dump(isset($a['hello']));           // FALSE

// The key 'hello' equals NULL so is considered unset
// If you want to check for NULL key values then try: 
var_dump(array_key_exists('hello', $a)); // TRUE

?>

(c) http://php.net/isset


-- 
Sincerely Yours, ANR Daemon <[EMAIL PROTECTED]>


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to