Testing Your Script

I l @ ve RuBoard

Unlike HTML, which can be tested on your own computer using a Web browser, in order to see what the output of your PHP script will look like, it needs to be saved to a PHP-enabled server. If you are working directly on a server, the script is already there once you've saved it. If you are creating your script using a text editor on your home computer, you will need to use FTP (file transfer protocol) to place it on the server. Your ISP or Web host should provide you with FTP access. You will also need an FTP application such as Fetch (for the Macintosh) or WS_FTP (for Windows).

To FTP your script to the server:

  1. Open your FTP application.

  2. Connect to the server, using the address, username, and password provided to you by your ISP or Web host (Figure 1.1).

    Figure 1.1. Fetch is a popular FTP application for the Macintosh, although there are others. Enter in your username and password that the ISP or Web host provided to you. If you know the directory where the files are to be stored, you could enter that here as well.

    graphics/01fig01.gif

  3. Find the proper directory for your HTML pages (e.g., www/ or htdocs/).

  4. Save your script ( test.php ) to the server. (As a rule, most FTP applications save transferred pages to the server with the same filename you are using for those files on your computer. If your particular FTP program gives you the option to specify the filename, use test.php. )

To test your script in the browser:

  1. Open your favorite Web browser.

  2. Enter the URL of the site where your script has been saved. (In my case, this is http://www.DMCinsights.com/php.)

  3. Add /test.php to the URL.

  4. Press Return. The page should load in your browser window (Figure 1.2).

    Figure 1.2. If you see the text phpinfo(); then either PHP is not installed correctly or the extension you used (.php in our case) is not treated as a PHP file.

    graphics/01fig02.gif

The phpinfo() function displays the system information for the PHP module installed on your server. It's handy for testing a new PHP installation, determining which PHP extensions are usable, and recording what PHP features are supported.

Tip

Some text editors, such as BBEdit, have built in FTP capability, allowing you to save your scripts directly to the server.


I l @ ve RuBoard


PHP for the World Wide Web (Visual QuickStart Guide)
PHP for the World Wide Web (Visual QuickStart Guide)
ISBN: 0201727870
EAN: 2147483647
Year: 2001
Pages: 116
Authors: Larry Ullman

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net