PHP Echo / Print

In PHP there is 2 ways to print output:

  • echo
  • print

echo is bit faster compare with print.

echo can output one or more strings

print can only output one string, and it returns value as 1.


echo is a language construct, and can be used with or without parentheses: echo or echo().

$txt = "test data";
echo $txt1;
echo "$txt1";
echo '$txt1';

test data
test data

If we use double quotes in echo statement, it will check both the variable data and string.

If we use single quotes in echo statement,  it will consider all data as string only.