PHP TutorialWhat 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 Types
PHP Conditional Statements
PHP Loop Type
PHP ArraysPHP String PHP Functions
PHP FormsForm Intro Get & Post Form Validation / Required PHP Complete Form
PHP AdvancedPHP 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 Handling
PHP 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
- 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"; ?>
- 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"; ?>
SEARCH POST HERE
Subscribe My YouTube Channel
Join Our Telegram Channel & Support Eachother
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”.
Subscribe to get the latest updates from Elevenstech Web Tutorials and stay up to date