[prev in list] [next in list] [prev in thread] [next in thread] 

List:       php-general
Subject:    [PHP] Re: Redundant isset() check?
From:       Dotan Cohen <dotancohen () gmail ! com>
Date:       2014-11-04 12:54:58
Message-ID: CAKDXFkNQXVSzXD53GTBqkMS16FJ7bvq72cn0o15y1FB+jWJGwA () mail ! gmail ! com
[Download RAW message or body]

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

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

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic