How to display output using PHP?


php How to display output using PHP? PHP Print R Function

Display one or more string using PHP

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

1- Using echo 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

2-Using Print and Printf Fucntion

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

3-Using Print_r Fucntion

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

Complete display output code

<?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
php PHP Print R Function Chapter Next »