What is the Diff. Between echo() and Print() in PHP?

Answer Posted / vinay sachan

There are many differences in print() and echo() :-

1-echo is unformatted whereas print is formatted.

2-echo() can take multiple expressions, Print cannot take multiple expressions.
ex.-
<?php
$name="Vinay";
echo "Name is $name";
//Value is Vinay

print 'Name is $name';
//Value is $name
?>

3-Print return true or false based on success or failure whereas echo just does what its told without letting you know whether or not it worked properly.

Is This Answer Correct ?    3 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is php stack?

529


How to get ip address of a server in php?

551


Is facebook still in php?

517


What is csrf verification?

533


What is move_uploaded_file in php?

553






What is the function to count elements in an array in PHP?

626


What does $globals mean?

525


Tell me what are magic methods?

536


What is difference between readonly and constant?

507


What is php and what does it do?

546


How do you end a function in python?

538


How to get best php developer Experience in Php with Sugar CRM / VTiger.

3975


Tell me what does the initials of php stand for?

556


Is false empty php?

550


What is the use of stripslashes in php?

539