Jump to content

"echo" or "print" ?


web_master

Recommended Posts

For a short discussion about the differences between print() and echo(), see this FAQTs Knowledge Base Article: http://www.faqts.com/knowledge_base/view.phtml/aid/1/fid/40

 

I prefer to use echo and its different forms.. like

 

<?= "print this" ?> short tag outputs

 

   echo <<<END

print whatever is here.. just like it is.

This is for some reason refered to as "here document" syntax.

adfa

df

a

d

a

<<<END

 

and the usual ones.

 

echo "hello";

 

echo ("hello");

 

I use print.. only as print_r() for printing arrays during debugging.

This function print_r() is very helpful for printing arrays in a structured manner.

 

For example:

 

$testArray = array("hello", "world");

print_r($testArray);

 

//outputs

array()

{

   [0] = hello

 

   [1] = world

}

Link to comment
https://forums.phpfreaks.com/topic/67438-echo-or-print/#findComment-338512
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.