Make PHP echo out the html in clean format


This might be a very simple question but I am not sure how to use PHP to echo out html in a very clean format.
Every time I use php to print out html element, I get sth like:
<div class="usercontent" style="display:block;">  
               <div id="dcdiv" style="background-color:#f3f3f3;  " ><form method="post" action="./../processrequest.php"><input type="hidden" id="req_type"" name="req_type" ..

But I would like to get sth like:
<div class="usercontent" style="display:block;">  
               <div id="dcdiv" style="background-color:#f3f3f3;  " >
                            <form method="post" action="./../processrequest.php">
                            <input type="hidden" id="req_type"" name="req_type" ..
Instead of all elements cramped to each other.

I tried using the new line in my echos but that didn't work. Maybe I am using it wrong. I also found sth like END ECHO >>.


Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

use \n for a newline and \t for a tab in your strings...
Dave BaldwinFixer of ProblemsCommented:
I usually add a "\r\n" at the end of each echo if I need to be able to read the srouce better.  Note that I used two sections in the code below.  The section I put single quotes around it because there were double quotes in the string and in the second I used double quotes because PHP will not consider "\r\n" to be a CRLF in a single quoted string, it will merely print or echo it as a literal.  You can also use "\t" for a horizontal tab if you want.
echo '<div id="dcdiv" style="background-color:#f3f3f3;" >'."\r\n";

Open in new window


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.