PDA

View Full Version : If / else stuff


Richard
05-19-2003, 04:44 PM
<?php
$page = $REQUEST_URI;
if ($page == "/xyz.php") { echo "hi"; }
if ($page == "/abc.php") { echo "hello"; }
if ($page == "/opq.php") { echo "whatever"; }
else { echo "Test"; }
?>


Is supposed to check if the page is any of those then to display different text. And if it isn't any of those, display 'Test'.

But it doesn't work unless it isn't the last one (/opq.php).

How do you make it so it applies to all the if statements ?

missing-score
05-19-2003, 04:59 PM
<?php
$page = $REQUEST_URI;
if ($page == "/xyz.php") { echo "hi"; }
elseif ($page == "/abc.php") { echo "hello"; }
elseif ($page == "/opq.php") { echo "whatever"; }
else { echo "Test"; }
?>


else applies to the last if statement, and group of elseifs.