When learning PHP, most people get introduced to the PHP functions with the most basic of all functions — the echo() function. The echo() function tells PHP to echo things into the browser’s viewing area. You can pass either variables or raw text to the echo function. Since we learned about PHP variables in the latter tutorial, I’ll start off by demonstrating how you can echo the information stored in variables using the echo() function. See the code below.
<?php
$variable = "hello";
echo($variable);
?>
The code above first sets the $variable variable to “hello”, and in the line immediately after that, uses the echo() function to output the text onto the screen. I highly recommend that you copy the code above into Notepad and save it as “echoscript.php”, and execute it. You will see that when you run the script, all that is displayed is “hello”.
Now, getting on to using the echo() with raw text. This is just as simple as using the function with variables, and requires no other knowledge. Please take a look at the code below.
<?php
echo("hi there");
?>
The above code outputs the text “hi there”. See? It’s simple. Remember, when using echo() with raw text, the text must be contained within quotations.