Re: Linebreak

From: Date: Fri, 21 Apr 2006 22:43:03 +0000
Subject: Re: Linebreak
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-234536@lists.php.net to get a copy of this message
Richard Lynch wrote:
On Thu, April 20, 2006 9:47 pm, Peter Lauri wrote:
I feel stupid. In many examples I have seen similar to: echo '<p>Whatever.</p>\n'; echo '<p>An other whatever.</p>\n'; But my PHP outputs the \n instead of a new line in the source. I am stupid?
No, just naive. :-) Quotes (") and Apostrophes (') are not QUITE the same in PHP. To some degree, they are VERY different. ' has only two (2) special characters: ' and \ " has a lot of special characters, and interpolates variables and one-dimension arrays.
just to add: you can interpolate any dimension of arrays (and objects for that matter) as long as you bother to escape the variables with braces inside the string e.g. $str = "my {$array['one']['two']['three']} string {$object->prop} interpolation";
\n only works in " not in ' Read this and you'll be WAY ahead of the game: http://us2.php.net/manual/en/language.types.string.php


« previous php.general (#234536) next »