Printing variables

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
farid
Forum Commoner
Posts: 54
Joined: Thu Nov 11, 2004 4:20 pm
Location: Mexico

Printing variables

Post 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]
method_man
Forum Contributor
Posts: 257
Joined: Sat Mar 19, 2005 1:38 am

help

Post by method_man »

<n> i believe
method_man
Forum Contributor
Posts: 257
Joined: Sat Mar 19, 2005 1:38 am

help

Post 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
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

<n>, is wrong.

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

\t is a tab character in string form.
method_man
Forum Contributor
Posts: 257
Joined: Sat Mar 19, 2005 1:38 am

?

Post by method_man »

hmm... what is <n> then? i remember it from somthing

matt
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

it isn't a tag that I know of.
method_man
Forum Contributor
Posts: 257
Joined: Sat Mar 19, 2005 1:38 am

nothin

Post by method_man »

hmm i read it in php/mysql for dummies book :D
good book for dummies like me lol

matt
Last edited by method_man on Tue Jun 21, 2005 12:17 am, edited 1 time in total.
User avatar
Ambush Commander
DevNet Master
Posts: 3698
Joined: Mon Oct 25, 2004 9:29 pm
Location: New Jersey, US

Post 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.
Post Reply