The article has been further recommended 1568 times.
E-Mailadresse
 




 FAQ Search
Produktkategorie: Hosting

How to change your PHP Version


Starting from the STRATO EasyWeb package upwards, you can choose to use PHP versions 5, 4.x and 3.

You can apply different versions on your webspace according to your personal taste, e.g. in one file PHP 5 and in another PHP 4.1, or you could also use different PHP versions depending on the file endings which you have specified in the particular PHP files.

Your webspace (FTP area) already has presets for every PHP version to which corresponding file extensions are assigned:

Version ---> Extension
PHP 3 ---> .php3, .phtml
PHP 4.x ---> .php, .php4
PHP 5.x ---> .php5

This means that without having to make any adjustments, all PHP files that are located on your webspace and ending with .php3 or .phtml, would be appropriately displayed in PHP version 3. Accordingly, all files with the ending .php or .php4 would be executed with PHP 4.x.
If you would like to use the latest version of PHP5, simply use the extension .php5 and you can start to enjoy the features that the latest PHP version has to offer.

By means of a small modification you also have the possibility of separately assigning the versions you would like to utilise. This is possible with the help of an .htaccess file.
This is a small file that can be uploaded to your FTP area that enables the server to associate different PHP file extensions with specific PHP versions. You can therefore not only assign a file extension with PHP 4.x, but for all PHP versions.

Open up a text editor program (e.g. in Windows XP select: Start -> Programs-> Accessories -> then "Editor" or "WordPad") to create a new document.
Highlight the following contents in the example below and copy them (right mouse key -> copy, or with the keyboard combination "CTRL" and "C") Subsequently insert the contents into the empty document of your text editor (right mouse key -> Paste, or with the keyboard combination "CTRL" and "V")

Example of the .htaccess-File
(Copy and paste into your text editor):

AddType application/x-httpd-php44 .php
AddType application/x-httpd-php4 .php4
AddType application/x-httpd-php5 .php5
Save the file on your computer as .htaccess.

Pay attention to the lower-case letters and the dot at the beginning of the name.
If it is not possible in your editor to save a file name that begins with a dot or without a .txt ending, just name the file .htaccess.txt at first.
Afterwards this file must be renamed, either before or after uploading to your FTP area (i.e. in your FTP area the file must be called .htaccess.

 

 

Upload the file via FTP to the root directory of your webspace. In many FTP programs the file can also be renamed after transfer, directly in the FTP area.

Explanation of the content of an .htaccess file.
The PHP version that you would like to associate with specific file extensions is shown on the left side of your .htaccess file. The term "AddType application/X-httpd-..." is always fixed and should not be altered. Directly after the "httpd" and the hyphen is the extension for the PHP version.

On the right side you can assign the file extension for the respective PHP version. The following extensions can be used: .phtml, .php3, .php4, .php5 and .php.

It is also possible to assign several file endings to a PHP version. For example, if you would like to rearrange all existing scripts with different file endings to PHP version 5, the contents of the .htaccess file must be as follows:
AddType application/x-httpd-php5 .php .php4 .php3 .php5
Range of .htaccess file.
If you place the .htaccess file in the root directory of your webspace it will apply to the root directory and all subdirectories. An .htaccess file can also be placed in any sub-folder. Should that be the case, then the .htaccess file in the root directory looses its effect for this particular folder.