How Do I Test a PHP File?

How Do I Test a PHP File? thumbnail
How Do I Test a PHP File?

PHP is an open source scripting language that's most often used for Web-based applications, but can also be used from the command line. How you test a PHP script (file) depends on what the script does and how the output is presented. If the script contains HTML code, the file should be tested on a Web server; if the file does not contain HTML code, it can be tested from the command line.

Instructions

  1. Command Line

    • 1

      Install PHP for your operating system. Linux users can use the software repository for their distribution. Windows users can download and install PHP from the PHP for Windows website (see Resources).

    • 2

      Open a terminal window (Linux) or a Command Prompt window (Windows). This will provide you with a command line where you will type the following commands.

    • 3

      Type the command \"cd php_directory\" (both Linux and Windows) to change to the directory where your PHP script is held. Change \"php_directory\" to the correct location for your script.

    • 4

      Type the command \"php script.php\" (Linux) or \"C:\\PHP5\\php.exe -f \"script.php\"\" (Windows) to execute the script. Change \"script.php\" to the correct name of your script.

    • 5

      Type \"exit\" to close the terminal window or Command Prompt window.

    Web Server

    • 6

      Upload your PHP file to your Web server.

    • 7

      Open a Web browser.

    • 8

      Type the address of the Web page containing your PHP code in the browser's address bar.

Tips & Warnings

  • If you don't have a Web server, you can install the Apache HTTP server, MySQL and PHP on your local computer. Linux users can install the software through the software repository for their distribution. Windows users can install EasyPHP (see Resources).

Related Searches:

References

Resources

  • Photo Credit Ciaran Griffin/Lifesize/Getty Images

Comments

You May Also Like

Related Ads

Featured