Re: TAB Syntax

From: Date: Wed, 30 Jun 2004 08:50:30 +0000
Subject: Re: TAB Syntax
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-189276@lists.php.net to get a copy of this message
Cheers Lars. So, for example, if I wanted to display some plain text tabbed I'd use: echo "<pre>string1\tstring2\tstring3</pre>"; There's just one problem though - it formats the text differently to the rest of the page (I'm using CSS to control this). Any thoughts...? -- ----------------------------- Michael Mason Arras People www.arraspeople.co.uk ----------------------------- "Lars Torben Wilson" <torben@php.net> wrote in message news:40E1F026.6060106@php.net... > Harlequin wrote: > > > I know I'm probably going to get flamed for this but it is only a > > development site but I am having some trouble getting the syntax right for > > using the tab when echoing information. My current command is: > > > > print_r("Host: $host<br>User: $user<br>Password: $password"); > > > > I've tried: > > > > print_r("Host: \t$host<br>User: $user<br>Password: $password"); > > > > and god knows what else with the brackets etc. > > > > Any ideas...? > > It's expected behaviour, when outputting to a web browser. Browsers fold > multiple whitespaces together. The two examples above should display > identically. Try wrapping the above outputs in <pre> tags, though, to see > the difference: > > <?php > $host = 'localhost'; > $user = 'torben'; > $password = 'none'; > > echo "<b>The next two examples should display identically</b><br>"; > echo "Host: $host<br>User: $user<br>Password: $password<br>"; > echo "Host: \t$host<br>User: $user<br>Password: $password<br><br>"; > > echo "Host: > > $host<br>User: $user<br>Password: $password<br>"; > echo "Host: \t$host<br>User:\n\n\t\n$user<br>Password: $password<br>"; > > > echo "<hr><b>The next two examples should display differently</b><br>"; > echo "<pre>Host: $host<br>User: $user<br>Password: $password<br></pre>"; > echo "<pre>Host: \t$host<br>User: $user<br>Password: $password<br></pre>"; > > echo "<pre>Host: > > $host<br>User: $user<br>Password: $password<br></pre>"; > echo "<pre>Host: \t$host<br>User:\n\n\t\n$user<br>Password: $password<br></pre>"; > > ?> > > > Hope this helps, > > Torben

« previous php.general (#189276) next »