Page 1 of 1

Printing variables

Posted: Wed Mar 23, 2005 5:15 pm
by farid
Hi!! I suppose this is an easy one for you,

Code: Select all

<?php

$var1="Test";
$var2="Testing";

echo $var1, "<br>", $var2, "<br>";

?>
In this code I can print with no problem the variables, but how could I print them with a tabs of space??

Thanks!!


feyd | Please review how to post code using

Code: Select all

and

Code: Select all

tags. Read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]

help

Posted: Wed Mar 23, 2005 5:22 pm
by method_man
<n> i believe

help

Posted: Wed Mar 23, 2005 5:25 pm
by method_man
it would look like this

Code: Select all

<?php

$var1="Test";
$var2="Testing";

echo $var1, "<n>", $var2, "<n>";

?>
but i think <n> mite be wrong

matt

Posted: Wed Mar 23, 2005 5:29 pm
by feyd
<n>, is wrong.

&#009; is a tab in html entity form.

\t is a tab character in string form.

?

Posted: Wed Mar 23, 2005 5:31 pm
by method_man
hmm... what is <n> then? i remember it from somthing

matt

Posted: Wed Mar 23, 2005 5:37 pm
by feyd
it isn't a tag that I know of.

nothin

Posted: Wed Mar 23, 2005 5:39 pm
by method_man
hmm i read it in php/mysql for dummies book :D
good book for dummies like me lol

matt

Posted: Wed Mar 23, 2005 7:34 pm
by Ambush Commander
Warning, the tab entity may not necessarily always actually return a tab (I fired up a quick HTML doc and tested it in FireFox and there was no visible difference)

If you don't care about HTML and want the tabs in the source, do this "\t" (tab escaped). If you really want tabs, try defining a constant that has something along the lines of this: "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" or check out this CSS solution:

Code: Select all

&lt;p&gt;One of the most dangerous errors of our time...&lt;/p&gt;

[syntax=php]p {
	margin:0 0 1em 0;
	}
#Content&gt;p {text-indent:2em; margin:0;}
#Content&gt;p+p {text-indent:2em; margin-top: 1ex;}[/syntax]

Note that this is a hack and only renders in FireFox, in IE the coding breaks down (which is also why it's got those Hash marks).

Best idea is to doublespace instead of relying on tabs to differentiate between paragraphs.