Re: Re: what's the difference in the following code?
| From: | Yeti | Date: | Sat, 18 Oct 2008 18:56:38 +0000 |
| Subject: | Re: Re: what's the difference in the following code? | ||
| References: | 1 2 3 4 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-282083@lists.php.net to get a copy of this message | ||
> Wrong. They are equivalent. The second is probably just easier to follow
> with a clearly defined default value outside the conditional block.
Well, leaving out the default value at the 2nd if statement makes a
difference and that's what I did.
Here is the code I changed again ..
Set to $_GET['search'] or an empty string
<?php
$search = isset($_GET['search']) ? $_GET['search'] : '';
?>
Only set if there is a $_GET['search']
<?php
// no default value <<<
if (isset($_GET['search'])) $search = $_GET['search'];
?>