Topic: \t\t\t\t\t ?!
I'm not a programmer. I have one PHP script that's full of this crap:
echo "\t\t\t\t" . '' . "\n";
What does \t\t\t\t and \n\t\t\t\t\t etc. do? Can I clean it up or is it essential?
You are not logged in. Please login or register.
PunBB Forums → Programming → \t\t\t\t\t ?!
I'm not a programmer. I have one PHP script that's full of this crap:
echo "\t\t\t\t" . '' . "\n";
What does \t\t\t\t and \n\t\t\t\t\t etc. do? Can I clean it up or is it essential?
It inserts tabs in the source code. The part you posted is useless though.
\n = Newline Unix-style
\r\n = Newline Wndows-style
\t = Tab
Usually used to output indented code (that's easier to read).
i've always been wondering as to what this code was for as well. So basically "\t\t\t\t" inserts 4 tabs?
Yes
It's there only to make the output pretty.
Thanks!
I'd rather have the input code looking pretty...
Obviously not a web designer either then. Trying to understand the output using view source when everything has ended up in a heap or, even worse, on one line, is no joke.
I agree in putting newlines in the code, but tabs is just a waste of perfectly good text imo. You can see what belongs where good enough, and with certain complex layouts you'd spend more time trying to get the tabs right than actually coding the backend.
I have to agree with Paul: it's MUCH easier to read with proper newlines and tabbing. Just like with source code, tabbing makes it easier to see where certain tags begin/end
I'm a little split on this myself actually. I do like the output to be pretty, but I have to agree, all those \n and \t in the code annoy the hell out of me.
When I'm lazy I usually just end the php block and type the html as usual
I'm a little split on this myself actually. I do like the output to be pretty, but I have to agree, all those \n and \t in the code annoy the hell out of me.
The cleaner alternative of course is to not to echo markup in which case html can be written as a block with new lines and indents. The result should be tidy source and output. The exception being imploded arrays which would still require new lines and tabs. The downside of course is constant switching between php and straight html.
The downside of course is constant switching between php and straight html.
Exactly. I'm not sure which I prefer.
I'd say the current way of doing it where we do one liners through echo, and multiple lines of html outside of php is the best way to go. It makes for much cleaner code and many times you don't want to output the html right away but store it in a variable, which force you to use php anyway
When I'm just writing HTML, I indent decently. But when I'm outputting stuff like options in a select, I just can't be arsed to go count the tabs really. The source is readable enough to debug and such, and that's all I need really.
PunBB Forums → Programming → \t\t\t\t\t ?!
Powered by PunBB, supported by Informer Technologies, Inc.