Re: Condition Checking

From: Date: Wed, 19 Jul 2000 18:12:37 +0000
Subject: Re: Condition Checking
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-7319@lists.php.net to get a copy of this message
In article <3975DADD.B8396E2D@pcraft.com>, ashley@pcraft.com ("Ashley M. Kirchner") wrote: It sounds like you want to echo out whatever file was requested. Your second if test should take care of the base case. I would suggest the following to handle any other. if ( ($REQUEST_URI == '/test/') || ($REQUEST_URI == '/test/index.php3') ) { echo "Test Index"; } else if (eregi("/test/(.)+",$REQUEST_URI,$file)) { echo $file[1]." requested"; } Jeff Warrington For this type of statement, remember that your first saved pattern match is in the [1] offset of the $file array (see docs). > > I'm trying to figure out if there's a better way to do this piece of > code: > > if ($REQUEST_URI == "/test/") { > echo "Test Index"; > elseif ($REQUEST_URI =="/test/index.php3") { > echo "Test Index"; > } > > Ideally, I'd like something like this: > > if (($REQUEST_URI == "/test/") || ($REQUEST_URI == > "/test/index.php3")) > echo "Test Index"; > } > > ...or however other method PHP supports... I don't know if it can > be done, or not. > > Some directories contain more than just a single file, and having to > check for each and everyone to figure out what to echo back will make > for a long script. Not very efficient either. > > Suggestions anyone? > > AMK4 > > -- > W | > | I haven't lost my mind; it's backed up on tape somewhere. > |____________________________________________________________________ > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > Ashley M. Kirchner <mailto:ashley@pcraft.com> . > 303.442.6410 x130 > SysAdmin / Websmith . 800.441.3873 x130 > Photo Craft Laboratories, Inc. . eFax 248.671.0909 > http://www.pcraft.com . 3550 > Arapahoe Ave > .................. . . . . Boulder, CO 80303 > > >

« previous php.general (#7319) next »