PHP Echo & Print Statements

In PHP, whenever we want to display anything or see the output, we use Echo and Print Statements.

Echo Statement

echo() statement takes a string of text and sends it as part of the Web page to the browser. The browser then displays the text to the visitor it is followed by a semicolon (;) at the end of the line which means that we have reached the end of the current statement and it should look for a new statement to follow or it is the end of the PHP code. Echo is not a function, it is a language construct as when we use function in PHP, it has a particular format

Syntax

echo ( string $arg1 [, string $... ] );

Example

<?php 
   echo "I am great.";
?> 

This will produce following result

I am great.

Print Statement

This is also used to send the output to the screen. An alternative to echo() is the print() statement. Print works exactly the same as Echo but the only difference is that it returns a value (true). We can use print() instead of echo() anywhere in our code wherever we like.

Syntax

print ( string $arg1 [, string $... ] );

Example

<?php 
   print "I am the greatest.";
?> 

This will produce following result

I am the greatest.


 
SHARE THIS IF YOU LIKE!
submit to reddit

SUBSCRIBE FOR LATEST UPDATES
HAVE WE CONNECTED ON FACEBOOK?
TOP TUTORIALSTOP CODE EXAMPLESTOP LIVE DEMOLINKSSTAY CONNECTED
HTML Tutorial
HTML5 Tutorial
Bootstrap3 Tutorial
Javascript Tutorial
TypeScript Tutorial
AngularJS Tutorial
CSharp Tutorial
PHP Tutorial
Developer Tools
Javascript
AngularJS
Google MAP API V3
ASP.NET
Javascript
AngularJS
Google MAP API V3
Contact Us
Advertise with Us
Privacy Policy
Disclaimer
Stay connected. We actually like you. If you want to get up to the minute updates, then connect with us on your fav below.
 
Twitter   Linkedin   Facebook   Google+    RSS   Pinterest
 
Protected by Copyscape Original Content Checker
 
 
Copyright ©2017 www.techstrikers.com Unauthorized reproduction/replication of any part of this site is prohibited.