How do I use PHP scripts?

This page is showing a generic answer.
To see a more detailed answer customized for you, type your domain name here:

Our Web hosting service allows you to use scripts created in the PHP programming language.

On this page:

Installing a PHP script

To install a PHP script, just follow these two rules:

  1. Name your PHP script so that it ends in ".php". For example, you could call a search script "search.php". (If you name a PHP script "index.php" and place it in a directory that does not contain an "index.html" or "index.htm" file, the PHP script will be displayed as the default file for that directory.)
  2. Use your FTP program to upload the script file in text (or "ASCII") mode, not "binary" mode. Although text mode is the default for most FTP programs, your PHP script may not work if accidentally uploaded in binary mode, so it's wise to check. Text mode is sometimes called "ASCII mode".

Using the script you installed

When your PHP script is installed, you'll be able to access it just like any other Web page. For example, if you named your script "search.php" and placed it in the top level of your website, you would access it as:

Sending email

If you send email from a PHP script, you'll probably want to make sure your script sets the correct "bounce" address.

PHP versions and phpinfo()

You can choose between different versions of PHP in our control panel.

If you want to know what versions of PHP we have available and view the “phpinfo()” output for each, please see our PHP versions page.

Changing php.ini settings

Certain aspects of the way PHP works are controlled through the server's “php.ini” file. For the most part, we use the default php.ini settings provided by the PHP authors.

We allow our customers to change these settings if they wish. To do so:

For example, if you wanted to change the default time zone that PHP uses, you could add this new line in that box:

date.timezone = "America/New_York"

Or if you need to force your scripts to send only secure cookies PCI compliance reasons, you could add:

session.cookie_secure = 1

PHP memory limits

Our default PHP memory_limit is 1000 MB (1 GB) of RAM for PHP 7.3 and later (it’s 500 MB for PHP 5.6 through 7.2, but we don’t recommend using older versions). In the unlikely event that your PHP script requires more than that, you can try to increase it by placing this type of line in the "php.ini" settings:

memory_limit = 1200M

However, you won't be able to increase it beyond the individual script memory limit shown on our Script Policies page — and in fact, it should be at least 100 MB less than shown there, because PHP itself uses some memory. If you try to go beyond that, the server will silently "kill" your script. It's better to keep the PHP memory_limit lower so that PHP shows a useful error message if a bug causes your script to use too much memory.

Can I use PEAR packages?

PEAR packages are files that contain prewritten PHP code. Some scripts use PEAR packages to perform tasks such as connecting to a database.

We do support PEAR, with many PEAR packages preinstalled. See our PEAR support page for more details.

Can I use Zend Optimizer, ionCube Loader or SourceGuardian Loader?

Zend Optimizer, ionCube Loader and SourceGuardian Loader allow you to run certain "encoded" PHP scripts. We have instructions explaining how to use them on our Zend Optimizer, ionCube Loader and SourceGuardian Loader pages.