Redundant isset() check?

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

 



Consider the situation where an application will use a different set
of PDO connection details depending on which version of the site is
running: production, dev, qa, cron job, etc. Considering that
$_SERVER['DOCUMENT_ROOT'] may not be set, is this check sufficient:

if ( !isset( !isset($connection_details[$_SERVER['DOCUMENT_ROOT']]) ) {

Or would it be preferable to first check that
$_SERVER['DOCUMENT_ROOT'] is set before relying on it:

if ( !isset($_SERVER['DOCUMENT_ROOT']) ||
!isset($connection_details[$_SERVER['DOCUMENT_ROOT']]) ) {

The TRUE case of this if clause will simply use the default connection details:
$connection_details[0]

-- 
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





[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