strings and whitespaces

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
Phraglord
Forum Newbie
Posts: 2
Joined: Wed Jul 03, 2002 10:53 am

strings and whitespaces

Post by Phraglord »

Hi there !

$mystring = " ";
print "mystring = [" . $mystring . "]";

The output of the print function is : mystring = [ ]
Why does it show only one of the spaces ?

thx !
User avatar
RandomEngy
Forum Contributor
Posts: 173
Joined: Wed Jun 26, 2002 3:24 pm
Contact:

Post by RandomEngy »

What other space? mystring only has one space.
User avatar
protokol
Forum Contributor
Posts: 353
Joined: Fri Jun 21, 2002 7:00 pm
Location: Cleveland, OH
Contact:

Re: strings and whitespaces

Post by protokol »

Phraglord wrote:Hi there !

$mystring = " ";
print "mystring = [" . $mystring . "]";

The output of the print function is : mystring = [ ]
Why does it show only one of the spaces ?

thx !
Use the code tags to display the code you are trying to use. It saves all your formatted text.
User avatar
Wayne
Forum Contributor
Posts: 339
Joined: Wed Jun 05, 2002 10:59 am

Post by Wayne »

If you are refering to why the HTML output only displays 1 of the spaces, this is because HTML formatting ingores whitespace. It will only display 1 space no matter how many you put in. If you want to keep the formatting either replace each space with   or else enclose what you want displayed within a

Code: Select all

<pre>output goes here</pre>
tag. If you use the <pre> tag though you will not be able to do HTML formatting on the text.

Hope that helps.
Phraglord
Forum Newbie
Posts: 2
Joined: Wed Jul 03, 2002 10:53 am

Post by Phraglord »

thx !
Post Reply