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

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Reply via email to