|
Posted by Jerry Stuckle on 09/28/05 21:55
Han Koster wrote:
> I use the following statements:
>
> $var = "";
> $var = $_POST('varname');
>
> In php 4, when 'varname' was not defined, $var remained an empty string;
> In php 5, I suddenly get errors.
>
> I solved these by including the function array_key_exist to check the
> occurence of 'varname'
> Is this the prefered way or is ther a better solution?
>
> Thanx,
> Han koster
>
>
Han,
You might have had display errors turned off in PHP 4.
It's always good to see if something exists before trying to use it. I
use isset($_POST['varname']), but I'm sure array_key_exist will work
just fine.
My code looks something like:
$var = isset($_POST['varname']) ? $_POST['varname'] : 'default_value';
That way I can set a default - even if it is null.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================
[Back to original message]
|