Re: isset
| From: | Burhan Khalid | Date: | Wed, 16 Feb 2005 06:47:16 +0000 |
| Subject: | Re: isset | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-208812@lists.php.net to get a copy of this message | ||
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?http://www.php.net/array-key-exists $cmd = array_key_exists('cmd',$_POST) ? $_POST['cmd'] : null;