[PHP] Date Problem with \n

2007-08-13 Thread Kevin Murphy

Small issue with formatting a date. If I type in this:

echo date(g:i:s a \o\n l F j, Y);

the n character in the word on doesn't appear, but instead what I  
get is a new line in the source code. If I type it as:


echo date(g:i:s a \on l F j, Y);

I get the number 8 (current month) where the n is supposed to be.

Is there any way to get an n in there?

--
Kevin Murphy
Webmaster: Information and Marketing Services
Western Nevada College
www.wnc.edu
775-445-3326

P.S. Please note that my e-mail and website address have changed from  
wncc.edu to wnc.edu.





Re: [PHP] Date Problem with \n

2007-08-13 Thread Jim Lucas

Kevin Murphy wrote:

Small issue with formatting a date. If I type in this:

echo date(g:i:s a \o\n l F j, Y);

the n character in the word on doesn't appear, but instead what I 
get is a new line in the source code. If I type it as:


echo date(g:i:s a \on l F j, Y);

I get the number 8 (current month) where the n is supposed to be.

Is there any way to get an n in there?



Use single quotes, then your \n will not be converted to a NL char

--
Jim Lucas

   Some men are born to greatness, some achieve greatness,
   and some have greatness thrust upon them.

Twelfth Night, Act II, Scene V
by William Shakespeare

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



Re: [PHP] Date Problem with \n

2007-08-13 Thread Richard Lynch
On Mon, August 13, 2007 12:50 pm, Kevin Murphy wrote:
 Small issue with formatting a date. If I type in this:

 echo date(g:i:s a \o\n l F j, Y);

 the n character in the word on doesn't appear, but instead what I
 get is a new line in the source code. If I type it as:

 echo date(g:i:s a \on l F j, Y);

 I get the number 8 (current month) where the n is supposed to be.

 Is there any way to get an n in there?

As noted, apostrophes will work in this case.

If you need to embed a variable, however, you may want to re-read this
from the manual a couple times:


You can prevent a recognized character in the format string from
being expanded by escaping it with a preceding backslash. If the
character with a backslash is already a special sequence, you may need
to also escape the backslash.

So, for example:

date(g:i:s a \o\\n l F j, Y);

Here's what happens:

PHP's string parser eats the \\ and turns it into a single
back-slash: \

*THEN* you have \n being passed to the C date() function, which then
eats the \n and says:
This is then not the n for Numeric representation of a month,
without leading zeros but just a regular old n as text.

-- 
Some people have a gift link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

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