PHP Exercise 2
Mixing HTML and PHP
<?php
if (strstr($_SERVER["HTTP_USER_AGENT"],
"MSIE"))
{
?>
<h3>strstr must have returned true</h3>
<center><b>You are using Internet Explorer</b></center>
<?php }
else {
?>
<h3>strstr must have returned false</h3>
<center><b>You are not using Internet
Explorer</b></center>
<?php }
· Notice here that instead of using echo() statements to print HTML code to the screen, we exited php with the ?> and went back to regular HTML code. Then when we were done with our HTML coding we entered back into PHP coding with <?php .
<?php
if
(strstr($_SERVER["HTTP_USER_AGENT"], "MSIE"))
{
echo "<h3>strstr must
have returned true</h3> <center><b>You are using Internet
Explorer</b></center> ";
}
else
{
echo "<h3>strstr must
have returned false</h3> <center><b>You are not using
Internet Explorer</b></center> ";
}
?>
·
Note: $_SERVER is a special reserved PHP variable that contains
all web server information. It's known as an Autoglobal (or Superglobal). All
predefined (Autoglobals) variables begin with $_ instead of just $. See
the related manual page on Autoglobals
for more information.
3.
From this point
forward, I will assume that you know HTML code. If you don't know HTML code,
please refer to http://www.pagetutor.com.