How to switch to a different PHP version?

While installing one of the WordPress plug-ins, there was a message that I was running the old version of php. I had to switch to a new one, version 5.0 or higher. I accomplished it by inserting a single line into .htaccess file:

AddHandler application/x-httpd-php5 .php .php5 .php4 .php3

If you want to switch to PHP 5.1, you should add the following line:

AddHandler application/x-httpd-php51 .php .php5 .php4 .php3

If you want to switch to PHP 5.2, you should add the following line:

AddHandler application/x-httpd-php52 .php .php5 .php4 .php3

If you have no .htaccess file you should create it and then write in it the necessary line. If you have .htaccess file, you should only edit it.

The .htaccess file can be placed into the directory or to the subdirectory in your hosting account. The PHP version can be changed for all the files in your hosting account, if the .htaccess file is located in the root directory of your account, or for a subdirectory, if it is located in the subdirectory. In my case, I had to put it to the subdirectory where all the files of my WordPress were located (public_html/myblog) in order to change php version only for my WordPress blog.