<?php $title = 'Conditionals I'; include '../head1.inc'; ?> Basic PHP conditionals look a lot like C. PHP does add and elseif, but writing else if works just as well. <p> This page is all about you. <p> <?php $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."; else 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?"; else echo "Happy browsing!"; $ua = $_SERVER["HTTP_USER_AGENT"]; 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."; else echo "unusual."; ?> </body> </html>