I take that back. I do think that || is the correct behaviour. If $_SERVER['DOCUMENT_ROOT'] is not set, then short-circuit and perform the TRUE portion of the if clause. If it is set, then check if $connection_details[$_SERVER['DOCUMENT_ROOT']] is set. I suppose that we could use DeMorgan's law to negate the negations, but then the code is less readable and clear. On Tue, Nov 4, 2014 at 2:07 PM, Dotan Cohen wrote: > On Tue, Nov 4, 2014 at 1:34 PM, Ashley Sheridan > wrote: >> You nearly had it, it should be something like: >> >> if ( !isset($_SERVER['DOCUMENT_ROOT']) && >> !isset($connection_details[$_SERVER['DOCUMENT_ROOT']]) ) { >> >> The reason for && and not || is that an kr can still fail on $_SERVER'[DOCUMENT_ROOT'] being set and still try to use it in the second part of the if(). The and will only return true if both are set. >> >> have you tested with warnings turned on (as they should be on every development environment) and tested with a non-existent $_SERVER array element? >> > > Thank you. At the point as which I asked the development code is not > yet written. On other projects I have done the initial (possibly > redundant) isset() check properly using &&, but for this mailing list > question I accidentally used ||. I agree, proper unit testing > discipline would have caught that! > > That you for letting me know that the check is not redundant. I do > prefer to have warnings turned on but not displayed to users on > production systems, of course! > > -- > Dotan Cohen > > http://gibberish.co.il > http://what-is-what.com -- 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