Posted by Jochem Maas on 08/14/05 02:25
Support wrote:
> ok....I got it!!
>
> not wanting to go down the path of the darkside...I inserted the
> superglobals..
>
> if (isset($_POST['gmev']) && in_array('September 9th', $_POST['gmev']))
>
> so did I get it right?
there are many roads to Rome. using isset() and in_array() is a
very good start indeed! (you'd be surprised at how many people don't check
vars at all) you might consider either casting $_POST['gmev']
as an array at some stage:
$myArr = (array)$_POST['gmev']
or also using is_array() to check that $_POST['gmev'] is actually an array.
another technique sometimes used is to suppress the error in cases when
you need speed AND you know the error is of no consequence:
if (@in_array('September 9th', @$_POST['gmev'])) {
// bla
}
notice 2 @ signs. the first suppresses the warning about possible in correct
2nd param to in_array() the second will suppress the notice if $_POST['gmev']
is not set.
be very wary of the @ sign - don't use it lightly, most always using isset()
in combination with a is_*() function is much much better (and more correct.
also check out the ctype functions:
http://php.net/ctype
>
[Back to original message]
|