Showing Output in PHP



PHP has a system for showing a result. This is done by echo. We can easily print value directly or the value of a variable by using echo. echo can print data or values anywhere of php code. It can be used inside function, class etc. Like other programming languages such as C or Java; PHP has also use built in function for showing a value. PHP has print_r()print(), printf() function. Most of the time these functions are not used. print_r function is used to show array date during development. It has not used to show data. print() function is used to format a string in a different way. printf() function does the same work as print();  echo is used widely in PHP programming by developers and coders also. The main advantage of this echo is that it can print any type of variable like string, float, double, bool, int etc. Let's see an example below for better clearance.


<?php

    echo 'We are learning php today';
?>

Output:


We are learning php today

Second Example


<?php

   $NUM = 50;
   echo $NUM;
   
?>

50

Anyone can easily print value by using this awesome echo that is available by php.