Re: TAB Syntax

From: Date: Tue, 29 Jun 2004 22:41:42 +0000
Subject: Re: TAB Syntax
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-189247@lists.php.net to get a copy of this message
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 (#189247) next »