PHP Echo / Print
echo and print are used to send output from PHP to the browser.
What is it?
echo and print are used to send output from PHP to the browser.
Why do we use it?
They display dynamic text, values and HTML generated by PHP.
How does it work?
PHP evaluates the expression and sends the resulting value to the response.
Syntax
echo value; print value;
Example
<?php $name = "AIFA Infotech"; echo $name; echo "<br>"; print "PHP Coding Lab"; ?>
Example Explained
More Examples
<?php echo "Total: " . (100 + 50); ?>
⚠️ Important Rules
echo is commonly used for normal PHP output.
❌ Common Mistakes
Incorrect quotes or trying to use undefined variables.
🌍 Real-World Use
Used to generate dynamic HTML and messages.
📝 Practice Exercise
Display your name, course, fee and institute using echo and print.
💻 Try It Yourself
Write and run this PHP lesson inside the AIFA Coding Lab.