Re: Can anyone improve on this?
| From: | Lee Doolan | Date: | Tue, 09 Apr 2002 00:10:40 +0000 |
| Subject: | Re: Can anyone improve on this? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-92148@lists.php.net to get a copy of this message | ||
>>>>> "George" == George Pitcher <fmdev@yahoo.co.uk> writes:
George> Hi all, I'm working on a small solution and want to do
George> some configuration during the initialising process.
George> The solution is aimed at non tecchies in universities and
George> the idea is that the system does some of the environment
George> stuff for them.
George> This is the first time I've done any of this stuff so I
George> might be off-target. Any suggested imptovements?
George> George
George> <?php
George> if(in_array("Windows_NT",$HTTP_ENV_VARS)){
George> $pdf_path="C:\\Pdf\\";
George> if(substr($SERVER_SOFTWARE,0,6)=="Apache"){
George> $webroot=$DOCUMENT_ROOT;
George> }elseif(substr($SERVER_SOFTWARE,0,13)=="Microsoft-IIS"){
George>
George> $webroot=str_replace(str_replace("/","",$PATH_INFO),"",$PATH_TRANSLATED);
George> }
George> }elseif(in_array("linux_gnu",$HTTP_ENV_VARS)){
George> $pdf_path="/var/pdf/";
George> if(substr($SERVER_SOFTWARE,0,6)=="Apache")
George> $webroot=$DOCUMENT_ROOT;
George> }
George> ?>
One thing that I like to do is to make sure that skip chains
are terminated with an else block. for instance:
if (COND A) {
statements for condition a
} else if (COND B) {
statements for cond b
} else if (COND C) {
statements for cond c
} else {
none of conditions A, B, C held
}
this is a personal preference, though, influenced by my distaste
for analyzing weird faults.
--
Share your feedback at Affero:
http://svcs.affero.net/rm.php?r=leed_25