Firstly we will look at how you can easily check your website's PHP version for any Hosting Provider and/or control panel. We will then cover how you can change the PHP version in DirectAdmin.
Checking the PHP version of your website or domain can be done via 2 simple methods.
Checking PHP version: Method 1 (Universal)
The cross-platform compatible way to check what PHP version your website is using (on any Host) is to create a file in your public_html directory containing PHP code to display the PHP version.
For example, open a text editor (notepad) on your local PC and create a new file called phpinfo.php. Simply enter into it:
<?php phpinfo(); ?>
Now upload this to your public_html directory via the DirectAdmin Filemanager, or FTP or SSH if you have that enabled. Then open up this page from your website https://yourwebsite.com/phpinfo.php. That will display a lot of detail about the current PHP version your website is using.
This is the ultra informative way to check your PHP version, and as you will see there is a tonne of useful and interesting details on this info page.
Checking PHP version: Method 2 (DirectAdmin specific)
Login to DirectAdmin and navigate to your site's main domain via:
Account Manager -> Domain Setup. Then click on your domain and you will be taken to a new screen. On the right of the screen you will see "PHP Version Selector", click on this and a dialog will open and you will see the current selected PHP version.
Changing your domain PHP version
Following on from "Checking PHP version: Method 2", assuming you have clicked on "PHP Version Selector", you can simply use the dialog to select the new PHP version you want and then click "Save".
That's it! Super Easy! Your domain will now use the PHP version you selected. Please note you may have to wait a few minutes until the change takes effect. Also, you can specify different PHP versions for different domains in your account, which is handy for those older sites that are not compatible with the latest PHP version.
Which PHP version should I use?
Whatever PHP version you choose is up to you and will likely be dictated by whatever software you are running on your domain. As a general rule of thumb, the latest (most recent) versions of PHP are always the better choice for security reasons. If you find yourself always having to use older versions of PHP it might be time to update your website's software so you can switch to the latest PHP version. Of course, always make sure you have downloaded a full account backup before you attempt any PHP software updates.