Skip to main content

HP is one of the most popular web programming language. Its widely used due to its simplicity, power and higher speed. It got really famous after its version 5 which was more Object oriented programming (OOP), then a more robust and high performance version 7 was released which was quickly adopted too by the software development industry. Now a days the latest version 8 is widely becoming popular.

In this article we will present some tips and lesser explored features of PHP.

Install mail function

It is not installed by default so you have to install it and then a little configuration is required.

sudo apt install sendmail

The run the following command and choose Y for all the options.

sudo sendmail config

Now edit the host file:

sudo nano /etc/hosts

And add or edit as:    localhost localhost.localdomain your_machine_name

To get your_machine_name run:



String output indentation on terminal

To print right aligned:

echo sprintf("%30s -> %s %s", 'S# ', 'Many Apples ', PHP_EOL);
echo sprintf("%30s -> %s %s", 'Serial number ', 'Many Mangoes ', PHP_EOL);



And to print left aligned (put a minus - in front of 30):

echo sprintf("%-30s -> %s %s", 'S# ', 'Many Apples ', PHP_EOL);
echo sprintf("%-30s -> %s %s", 'Serial number ', 'Many Mangoes ', PHP_EOL);