Practice 1

Main | Static vs. Dynamic Websites | Using PHP | A Simple PHP Program | Variables and Operators | Practice 1 | Solution 1 | Loops | Practice 2 | Solution 2 | Functions | Practice 3 | Solution 3 | Conditionals | Practice 4 | Solution 4

In this exercise you will create a PHP program that tells a person visiting your site the following information:

  • What browser they are using.
  • What IP address they are using.

To see what this program looks like when it is run, click here.

To complete this exercise you must:

  1. Create a file in "public_html/php" called "browsIP.php".
  2. Make "browsIP.php" viewable from the web.
  3. Fill in "browsIP.php" with this incomplete code.
  4. Complete the PHP section of the incomplete code and run your program.

HINT: To complete the missing PHP code above you must use special variable names that are reserved. The variable name for the browser type is $HTTP_USER_AGENT and the variable name for the IP address of the person using the PHP program is $REMOTE_ADDR.

HINT: Use echo to display the dynamic value contained in the appropriate variable.


jfulton [at] member.fsf.org
22 Aug 2013