Home » questions » PHP: Is there a way to add space in the output file?

PHP: Is there a way to add space in the output file?

2006-08-18 11:59:01, Category: Programming & Design
How do I give additional line breaks and spacing in a PHP output file. When PHP output a HTML file with echoes, it looks terrible without line breaks (although it looks fine on browser, but I find it terribly confusing to verify the generated code without the line breaks, and I'm also a neat person) Note: if you're saying, add
just get out from here, that's not what I'm asking. what I mean: PHP input File is like: ---- ---- *PHP Output File* is like: ---- the things here is generated by PHP ---- and Browser Viewed: ---- THIS TEXT IS BOLD (just imagine the all caps is bolded, since we can't use formatting in YA) ---- I think Garfieldswingsquisshy (forgive me if it's mistyped) has given the correct answer, thanks gar, I'll choose the best answer to you as soon as I'm online next time, and the 4 hour wait period finished. Additional question: How about tabbing? sheeple_rancher also gives a good explanation, geez I wish I could give the points to more than one good answerers. sheeple_rancher also gives a good explanation thanks, geez I wish I could give the points to more than one good answerers.

Answers

  1. Irishtek

    On 2006-08-18 12:11:03


    I think the question is somewhat confusing because you mention a PHP output file. It sounds like you want to view the code that you are writing a little easier by adding breaks. (assuming you know you can just add breaks it won't matter; therefore I'm missing what you mean by output file) it sounds like the view in the browser - which you specified that's not what you are talking about. Becauser you are not intereseted in the
    tag - i'm also gathering the

    is also undesirable If you wouldn't mind further elaboration so I know what is needed in your answer that'd be great.

  2. garfieldswingssquishy

    On 2006-08-18 12:12:05


    echo ("\r\n"); Hey... thanks... yeah, like he said, it has to be in double quotes... put it anywhere in the echo'd code that you want PHP to generate a carriage return. \r is carriage return \n is new line Sometimes, depending on "whatever I dont know", a \r will work, sometimes a \n will work, sometimes you need both \r\n As for your tabbing??? I think that is \t but Im not sure
  3. rp_joe

    On 2006-08-18 12:05:06


    What happens when you use

    ?

  4. sheeple_rancher

    On 2006-08-18 12:22:43


    I know exactly what you want. print '

    Here is line 1

    ' . "\n"; print '

    Here is line 2

    ' . "\n"; print "

    Here is \nline 3

    " . "\n"; shows up as:

    Here is line 1

    Here is line 2

    Here is line 3

    Note that \n is a newlinie and for it to be interpreted in a string rather than just output as the two charactrs, you have to enclose it in double quotes (look closely at line 3). Adding the "\n" at the end (or wherever) will break up the raw html. You can turn the "\n" into a macro like EOL to make typing it easier.
  5. Michael T

    On 2006-08-18 13:06:51


    also: echo "my first line
    "; echo "my second line
    ";