PHP: How i enable PHP version 7.4 and disable PHP version 7.3

 In this PHP Tutorial, I will let you know how to install PHP version from 7.3 to 7.4 using command on your linux machine.

There are some cases in which you have to upgrade your PHP version but before upgrading to any version from previous one, you should be always aware from its incompatibilities.

There is very simple step that you need to follow to update your PHP version to newest.

First, You need to add the PPA ondrej/php which will provide the PHP 7.4 package and other required PHP extensions







After successfully adding the PPA, you can install any version of PHP 7.

sudo apt install php7.4


Now you can run following command to install commanly used php-extensions:

sudo apt install php7.4-common php7.4-mysql php7.4-xml php7.4-xmlrpc php7.4-curl php7.4-gd php7.4-imagick php7.4-cli php7.4-dev php7.4-imap php7.4-mbstring php7.4-opcache php7.4-soap php7.4-zip php7.4-intl -y


If you are using PostgreSQL for database connection then you need to install below extension :

sudo apt-get install php7.4-pgsql

If you have already installed any other version of PHP then you should disable that version first and then enable the current version of PHP that you want to use for your application by running following command:


sudo a2dismod php7.3

sudo a2enmod php7.4


Now restart your apache server by running below command:


sudo service apache2 restart

You are done with the steps and now you can check the PHP version by running following command:

php -v





Write a program in PHP to reverse a number

A number can be written in reverse order. For example 12345 = 54321 <?php   $ num = 23456;   $ revnum = 0;   while ($ num > 1)   {   $...