×
×
PHP Tutorial
What is PHP Environment Setup of PHP PHP Syntax PHP Comments PHP Echo & print PHP Variables PHP Scope Variables PHP $ and $$ Variable PHP Constants PHP Operators PHP Data TypesPHP Conditional Statements
PHP Loop Type
PHP Arrays
PHP String PHP FunctionsPHP Form Examples
Form Intro Get & Post Form Validation / Required PHP Complete FormPHP Advanced
PHP Include / Require PHP Date & Time PHP Session PHP Cookies PHP File Handling PHP Open File PHP Read File PHP Write File PHP Append File PHP Delete File PHP File Upload PHP Sending Mail PHP Error HandlingPHP Echo & print
In this tutorial, we will teach you how to use echo and print statements to display the result of php code.
In PHP, echo and print both are language construct not actually a function. Therefore, there is no requirment of parenthesis.
Difference between echo and print
In Echo
- echo is used to show the output of PHP code
- It can be used with or without paranthesis. Like echo or echo().
- echo has no return value.
- we can pass multiple arguments by using comma (,) saparated.
- echo is marginally faster than print.
Example of Echo:
<?php
echo "This is my first string";
//pass multiple arguments by using comma (,) saparated
echo "This","is","my","second","string";
?>
In Print
- print is also used to show the output of PHP code.
- It can be used with or without paranthesis. Like print or print().
- print has a return value of integer 1 so it can be used in expression.
- print can take one argument. We can't pass multiple arguments.
- print is slower than echo
Example of Print:
<?php
print "This is my first string";
?>
Elevenstech Web Tutorials
Elevenstech Web Tutorials helps you learn coding skills and enhance your skills you want.
As part of Elevenstech's Blog, Elevenstech Web Tutorials contributes to our mission of “helping people learn coding online”.
Read More
Newsletter
Subscribe to get the latest updates from Elevenstech Web Tutorials and stay up to date
Copyright 2018 - 2024 Elevenstech Web Tutorials All rights reserved.