There are three PHP functions that are used to display the output 1- Using echo Function 2- Using Print Function 3- Using Print_r Function
Mostly for displaying the output we use the echo function .
Echo function starts with keyword "echo" then we write the output strings in qoutes , then ends with semicolon.
Example.
<?php echo "Hello Word"; ?>
Output: Hello World
We can also show the output using print function.
Print function starts with function name "print" . We have to pass the strings in the print function as a functional parameter, then ends with semicolon.
Example.
<?php print("Hello world by print function"); ?>
Output: Hello world by print function
We can also show the output using print_r function.
The actual use of print_r function is to display data in easy human-readable form. If we display an array using print_r function it will display array in easy human readable form. In future chapters we will discuss the actual use of print_r function with examples.
Print_r function starts with function name "print_r" . We have to pass the strings in the print_r function as a functional parameter, then ends with semicolon.
Example.
<?php print_r("Hello world by print_r function"); ?>
Output: Hello world by print_r function
<?php
echo "I am output by echo function.";
print("I am output by print function.");
printf("I am output by printf function.");
print_r("I am output by print_r function.");
?>
In the next chapter we are going to discuss the PHP variable . Let's continue