Re: Redundant isset() check?
| From: | Dotan Cohen | Date: | Tue, 04 Nov 2014 12:54:58 +0000 |
| Subject: | Re: Redundant isset() check? | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-324035@lists.php.net to get a copy of this message | ||
On Tue, Nov 4, 2014 at 2:37 PM, Christoph Becker <cmbecker69@gmx.de> wrote:
> Then you might consider using the following:
>
> $index = isset($_SERVER['DOCUMENT_ROOT'])
> ? $_SERVER['DOCUMENT_ROOT'] : 0;
> do_something_with($connection_details[$index]);
>
> BTW: after upgrading to PHP 7 you could use the null coalesce operator[1]:
>
> $index = $_SERVER['DOCUMENT_ROOT'] ?? 0;
>
> [1] <https://wiki.php.net/rfc/isset_ternary>
>
Thank you.
--
Dotan Cohen
http://gibberish.co.il
http://what-is-what.com