Facbook Pixel



Creating PHP pages

PHP is automatically enabled in all of our hosting accounts. Once you activate your hosting account, you can create and upload PHP pages.

There are several good (and often free) PHP editors available for writing your PHP code. However, you can use any text editor program to write a PHP file. After you have written the PHP code, simply name the file with a ".php" extension and upload it to the site directory on your hosting account.

Your First PHP Page

If you're familiar with HTML, PHP is a straightforward language to learn. Once you learn the basic syntax, you can explore more advanced features of PHP. To create your first PHP page:

  1. Open your favorite text editor.
  2. Type the following code into your text editor:
    <html><title>PHP Test</title><?phpecho "Hi, I'm a PHP script!";?></html>

    Notice how The PHP code is enclosed in special start and end tags. These allow you to jump into and out of "PHP mode."

  3. Save your file as hello.php and close the text editor. If you're using Windows Notepad, ensure that the the ".php" replaces the ".txt" extension when saving your file.
  4. Upload your new PHP file to the site folder of your hosting account. For more information, see What is FTP?.
  5. Use a web browser to access the file by typing in your site's domain name, followed by /hello.php. For example, coolexample.com/hello.php.

If everything is configured correctly, PHP will convert the code between short tags and display the text "Hi, I'm a PHP script!" in your browser.

Note: If you tried this example and it did not display correctly, remember to upload the file to your hosting account. If you try to view this PHP file on your computer, it will not work as the file needs to be viewed on a hosting account that runs PHP.

Your Second PHP Page

One of the most popular PHP scripts is one that calls the phpinfo() function. The phpinfo() function displays useful information about your system and setup like available predefined variables, loaded PHP modules and configuration settings. To utilize this phpinfo() function:

  1. Open your text editor.
  2. Type the following code into your text editor:
    <html><title>PHP Info</title><?php phpinfo(); ?></html>
  3. Save your file as info.php and close the text editor. If you're using Windows Notepad, ensure that the the ".php" replaces the ".txt" extension when saving your file.
  4. Upload your new PHP file to the site folder of your hosting account. For more information, see What is FTP?.
  5. Use a web browser to access the file by typing in your site's domain name, followed by /info.php. For example, coolexample.com/info.php.

If everything is configured correctly, PHP will convert the code between the short tags and display your hosting account's PHP information in your browser.

Next Steps