Re: Newline

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



In general, I try to think of single quotes as being literal and double quotes as being interpreted.

In that case, we expect 'some line\t with a tab, a variable {$obj- >member}, and a newline\n' to produce exactly:
some line\t with a tab, a variable {$obj->member}, and a newline\n

Yet, the same thing in double quotes:
some line	 with a tab, a variable foo, and a
 newline

As a result, I use single quotes whenever I can.  Otherwise, double.

Jeremy Mcentire
Ant Farmer
ZooToo LLC


On Oct 29, 2007, at 6:15 AM, Nathan Nobbe wrote:

On 10/29/07, Crayon Shin Chan <crayon.shin.chan.uk@xxxxxxxxx> wrote:

On Sunday 28 October 2007, magoo wrote:

I have switched to using single quotes, and found out that newline (\n)
only works in double quotes. It looks kind of stupid using
'someString'."\n"; and it`s kind of inconsistent using double quotes
for some lines like "someString\n";.

You can:

        define('LF', "\n");

then

        echo 'A newline' . LF;

or something


if you were going to do that you may as well use PHP_EOL
its cross-platform and doesnt require an define directive.
(php5 only)

-nathan

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


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux