How to Build a PHP File

How to Build a PHP File thumbnail
PHP powers many popular Web applications.

The creator of the PHP programming language needed a tool to help him maintain his personal website. The scope and capabilities of PHP have grown far beyond its humble beginning. Today PHP is the language powering online educational systems, search engines, social networks, online games and millions of blogs. Despite its power, PHP is an accessible language. Most Web hosts offer PHP as a scripting language. A Web developer needs only a text editor, Web browser and File Transfer Protocol (FTP) application to begin programming with PHP.

Things You'll Need

  • Plain Text Editor
  • Access to a Web server with PHP installed
  • FTP (File Transfer Protocol) application
Show More

Instructions

    • 1

      Launch the plain-text text editor application on your system, such as Notepad on a PC; Jedit or Gedit on Linux systems; or Komodo Edit, Smultron, BBEdit or TextMate on Mac OS X.

    • 2

      Type the following PHP code in the text editor:

      <?php

      echo 'hello world';

      ?>

    • 3

      Click on the File menu and select "Save." Name the file "myphpfile.php."

    • 4

      Click on the File menu and select "Quit" or "Exit" to close the text editor.

    • 5

      Launch the FTP application and log in to the Web server.

    • 6

      Upload the file "myphpfile.php" to the root directory of the Web server.

    • 7

      Click on the "Disconnect" button of the FTP application.

    • 8

      Launch a Web browser, then enter the appropriate URL to access the PHP file. An example would be:

      http://yourdomainname.com/myphpfile.php

      Replace "yourdomainname.com" with the domain name or IP address of the Web server.

    • 9

      Press the enter key to load the URL and run the PHP file. The browser should display "hello World."

Tips & Warnings

  • PHP developers can test code on their Windows or Linux computer by downloading and installing the local Web server packages EasyPHP or Xampp. EasyPHP is for Windows systems only: Xampp has versions available for Windows, Linux and Mac OS X systems. EasyPHP and Xampp provide a preconfigured, ready-to-use Apache Web server, PHP interpreter and MySQL database.

  • Most Web servers will not process PHP files that do not end with the .php extension. Some servers recognize .phtml, .php4, .php3, .php5, and .phps as valid extensions, as well, but .php is the standard.

Related Searches:

References

Resources

  • Photo Credit Jupiterimages/Photos.com/Getty Images

Comments

Related Ads

Featured