RE: [PHP] must be a better way

From: Date: Tue, 17 Oct 2000 22:49:03 +0000
Subject: RE: [PHP] must be a better way
Groups: php.general 
Request: Send a blank email to php-general+get-20724@lists.php.net to get a copy of this message
if (ereg ("services", $PHP_SELF)) { $header = "Available Services"; } elseif (ereg ("about", $PHP_SELF)) { $header = "About the Company"; } else { $header = "Welcome"; } Or if you want it more compact, you don't need the {}'s if it's only one line of content after the if statements. if (ereg ("services", $PHP_SELF)) $header = "Available Services"; elseif (ereg ("about", $PHP_SELF)) $header = "About the Company"; else $header = "Welcome"; As usual, http://www.php.net/manual/control-structures.elseif.php has all the info you need. Nick > -----Original Message----- > From: Jerry Lake [mailto:jerryl@europa.com] > Sent: Wednesday, 18 October 2000 9:14 > To: php-general@lists.php.net > Subject: [PHP] must be a better way > > > I know there is a better way to express what I have here > I just can't think of it today... > > if (ereg ("services", $PHP_SELF)) > { > $header = "Available Services"; > } > else > { > $header = "Welcome"; > } > > if (ereg ("about", $PHP_SELF)) > { > $header = "About the Company"; > } > else > { > $header = "Welcome"; > } > > would it be like this, maybe? > if (ereg ("something", $string)) > { > $something = "this"; > } > else > { > $something = "that"; > } > elseif (ereg ("somethingelse", $string)) > { > $something = "this"; > } > > additionally is there a way to declare 2+ variables > for one true outcome i.e. > if (true) { > $item = "something"&& > $item2 = "somethingelse"; } > > > Jerry Lake - jerryl@europa.com > Web Designer > Europa Communications - http://www.europa.com > Pacifier Online - http://www.pacifier.com > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > For additional commands, e-mail: php-general-help@lists.php.net > To contact the list administrators, e-mail: > php-list-admin@lists.php.net > >

« previous php.general (#20724) next »