Re: isset

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



D_c wrote:
I often use this type of construct

$cmd = $_POST['cmd'];
if ($cmd == null) { // do default

but this throws a notice if the ['cmd'] index is not defined. ugly.
using


if (isset($_POST['cmd'] ) {
$cmd = $_POST['cmd'];
}


seems lengthy. is there a way around this?

i tried using $cmd = @ $_POST['cmd'];

to suppress errors but didnt seem to have ay effect.

tx.


still
if(isset($_POST['cmd'])) {
   $cmd = $_POST['cmd'];
}

is the only (really) correct way. All others throw notices of undefined indices, which you *should not* ignore! You can't shorten it, you can't even wrap it in a function... it's simply tough luck

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


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux