character Tab in php and C++

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
php12342005
Forum Commoner
Posts: 79
Joined: Mon Mar 21, 2005 3:35 am

character Tab in php and C++

Post by php12342005 »

I am wondering if such characters can be used in php, which can be used in C++:

characters:
Tab: \t
Line break: \n
etc.

I have to use <br> for \n (it works).
But what TAG or something are similar to \t in php?

\t is useful for displaying (echo or print) text nicer.

thanks
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

Those characters work in any language where you are outputting ascii code.

So yes they work. You dont have to use <br> for \n...

Don't forget what PHP does ;) It outputs the HTML source code so thats where your tabs and linebreaks are...

A tab in HTML if that's what you're asking, is &#09;
php12342005
Forum Commoner
Posts: 79
Joined: Mon Mar 21, 2005 3:35 am

Post by php12342005 »

Hi,
I tested your comment:

add php code:
-----------------------------
print("hello&#09&#09&#09\n");
print("hello&#09&#09&#09\n");

output is
-----------------
hello hello

You see, only one space character between 2 "hello"s
I think the space char is "\n" rather than Tab
so it looks Tab (&#09) doesn't work.
User avatar
nielsene
DevNet Resident
Posts: 1834
Joined: Fri Aug 16, 2002 8:57 am
Location: Watertown, MA

Post by nielsene »

php12342005 wrote:Hi,
I tested your comment:

add php code:
-----------------------------
print("hello&#09&#09&#09\n");
print("hello&#09&#09&#09\n");

output is
-----------------
hello hello

You see, only one space character between 2 "hello"s
I think the space char is "\n" rather than Tab
so it looks Tab (&#09) doesn't work.
you need the semi-colon &#09; to terminate an "html entity reference".
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

You're missing your semi-colons after &#09;

It is the correct and documented ascii code for it :?

&ht; (horizontal tab) may also work but I'd recommend going with numbered entities for that sort of thing.

Is there a reason you really must use tab? You can use &nbsp; multiple times OR lay your data out in tables or with CSS for the best control over presentation.
php12342005
Forum Commoner
Posts: 79
Joined: Mon Mar 21, 2005 3:35 am

Post by php12342005 »

is code this way?
print("hello \n");
print("hello \n");

but output is the same.
(&#09 with a semi-colon can not be desplayed)
Last edited by php12342005 on Sat Jul 23, 2005 12:09 pm, edited 3 times in total.
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

I wouldn't work up a sweat over it. It's not something that's commonly used in presentation and perhaps not supported on some browsers (I think there's only 3 ascii chars in the range 0-31 or something which are actually allowed in HTML).

Try using &nbsp; or doing the proper thing and using CSS or tables ;)
User avatar
nielsene
DevNet Resident
Posts: 1834
Joined: Fri Aug 16, 2002 8:57 am
Location: Watertown, MA

Post by nielsene »

php12342005 wrote:is code this way?
print("hello \n");
print("hello \n");

but output is the same.
(&#09 with a semi-colon can not be desplayed)
Are you viewing the output on a browser? in the 'view source" of a browser, or on the command-line?
Post Reply