# Using Echo and print to dynamically build HTML files

**URL:** <https://forum.kirupa.com/t/using-echo-and-print-to-dynamically-build-html-files/269495>\
**Category:** programming\
**Created:** [August 28, 2008, 11:21am UTC](https://forum.kirupa.com/t/using-echo-and-print-to-dynamically-build-html-files/269495 "2008-08-28T11:21:49Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![java\_ftp\_er](https://avatars.discourse-cdn.com/v4/letter/j/96bed5/32.png) [@java\_ftp\_er](https://forum.kirupa.com/u/java_ftp_er)\
**Post date:** [August 28, 2008, 11:21am UTC](https://forum.kirupa.com/t/using-echo-and-print-to-dynamically-build-html-files/269495/1 "2008-08-28T11:21:49Z")

</div>

I have searched this forum and have read a couple of your articles such as

–[http://www.kirupa.com/web/phphtml.htm](http://www.kirupa.com/web/phphtml.htm).

however I’m still unsure whether I should use Echo (that I use on the command

line) or print – what is the difference?

The reason I ask is because I have written a few HTML files using PHP and I end up

with one extremely long line of HTML! It is still valid and the Web browser

displays the page correctly however I want to display the HTML in a much more

readable form (each tag on its own line).I have tried Echo and print and they both

appeared to be the same.

for example:

\<!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.01 Transitional//EN”\>  
\<html\>

\<?php  
print “\<p\>Can gophers really code PHP?\</p\>”;  
print “\<p\> if I can they can \</p\>”;  
print “\<p\> I’m getting bored now \</p\>”;  
?\>  
\</body\>  
\</html\>

Results in the following HTML file (same with the echo command): –  
\<html\>  
\<body\>  
\<p\>Can gophers really code PHP?\</p\>\<p\> if I can they can \</p\>\<p\> I’m getting bored

now \</p\>\</body\>  
\</html\>

whereas I want: –  
\<html\>  
\<body\>  
\<p\>Can gophers really code PHP?\</p\>  
\<p\> if I can they can \</p\>  
\<p\> I’m getting bored now \</p\>\</body\>  
\</html\>

I have played about a bit will escape characters but I have been unable to achieve

the desired result.

Can anyone help me with this? Any thoughts greatly appreciated.

hhh
