PHP Tutorial
How is PHP is useful?
The next script you'll create is one that can be used to determine what kind of
browser a users may be using on their local computer to browse your website.
This is an example of the PHP script you can use inside of your hello_world.php3
script.
<html>
<head>
<title>Hello World - Browser Type</title>
</head>
<body>
<?
#!/usr/local/bin/php
echo "Hello World!";
echo $HTTP_USER_AGENT; ?>
</body>
</html>
The browser type is displayed due to the PHP script being parsed, or read
through. This command can be used several ways. One way that a webmaster / web
designer may find useful is to redirect users to different pages of a website
based upon their browser type. Here's an example of the script that can be used
to accomplish just that.
<html>
<head>
<title>Hello World - Browser Type</title>
<? #!/usr/local/bin/php
if(strstr($HTTP_USER_AGENT,"MSIE")) {
echo "<META HTTP-EQUIV=Refresh Content =\"0;
URL=http://domain.com/ie.html\"> ";
}
else {
echo "<META HTTP-EQUIV=Refresh Content =\"0; URL=http://domain.com/other.html/\">
";
}
?> </head>
<body>
</body>
</html>