You can easily change the PHP version of your site by logging into your Cpanel hosting account. Here are the steps:
- Log in to cPanel for your account
- Go to Software section -> PHP Version Manager or PHP Configuration
- Choose the version you want to use from the dropdown (pls note that this change will also apply to all the subdirectories inside)
- Once chosen, save the option.
This will automatically add a line similar to the one below to your .htaccess file located in your root folder.
AddHandler application/x-httpd-recommended-php .php .php5 .php4 .php3
You can also apply the changes manually, without using the PHP Version Manager in cPanel. To do so add one of the following directives in the .htaccess file of your website:
For changing to PHP 7.4
AddHandler application/x-httpd-php74 .php .php5 .php4 .php3
For changing to PHP 7.3
AddHandler application/x-httpd-php73 .php .php5 .php4 .php3
For changing to PHP 7.2
AddHandler application/x-httpd-php72 .php .php5 .php4 .php3
For changing to PHP 7.1
AddHandler application/x-httpd-php71 .php .php5 .php4 .php3
For changing to PHP 7.0
AddHandler application/x-httpd-php70 .php .php5 .php4 .php3
For changing to PHP 5.6
AddHandler application/x-httpd-php56 .php .php5 .php4 .php3
Note that this will change the PHP version not just for the folder/site but also for all of its sub folders.