PHP Code Examples
[Download]   [Execute]
<?php $title = 'Conditionals I'; include '../'; ?>

Basic PHP conditionals look a lot like C.
PHP does add and elseif, but writing else if works just as well.
This page is all about you.
$now = getdate();

echo "Good ";

if($now["hours"] < 9)
	echo "morning.";
else if($now["hours"] < 12)
	echo "day.";
else if($now["hours"] < 17)
	echo "afternoon.";
else if($now["hours"] < 20)
	echo "evening.";
	echo "night.";
echo "  ";

if($now["wday"] == 0 || $now["wday"] == 6) 
	echo "Little weekend surfing, I see.";
else if(17 < $now["hours"] && $now["hours"] < 23)
	echo "Working late?";
else if($now["hours"] < 8 || $now["hours"] >= 23)
	echo "Don't you ever sleep?";
	echo "Happy browsing!";

echo "<p>Your browser is ";
if(preg_match("/MSIE/i", $ua))
	echo "boringly conventional.";
elseif(preg_match("/opera/i", $ua))
	echo "something to sing about.";
elseif(preg_match("/lynx|links/i", $ua))
	echo "minimal.";
elseif(preg_match("/netscape/i", $ua))
	echo "getting kind of crusty.";
elseif(preg_match("/firefox/i", $ua))
	echo "progressive.";
	echo "unusual.";