How to use print command In PHP
The run time of the print function in PHP is slightly more than that of echo function.
Example 1:
<?php
$string = "w3wiki!!";
// Printing the string directly
print("Printing the string: ");
// Printing the variable
print $string;
?>
Output
Printing the string: w3wiki!!
Example 2: Arrays can be printed using the print_r method which is used to print the index along with its values.
<?php
// Declaring an array
$arr = array(1, 2, 3, 4, 5);
echo('Array : ');
// Printing array
print_r($arr);
?>
Output
Array : Array ( [0] => 1 [1] => 2 [2] => 3 [3] => 4 [4] => 5 )
How to display text with a PHP script ?
PHP allows us to display the text in various formats using various inbuilt methods.
Contact Us