Re: Digest for intro2php-matt-2011-01@googlegroups.com - 2 Messages in 1 Topic

6 views
Skip to first unread message

Kristin Robinson

unread,
Feb 6, 2011, 4:00:39 PM2/6/11
to intro2php-m...@googlegroups.com
Perfect!  Always good to know I'm not crazy.

On 6 February 2011 12:57, <intro2php-matt-...@googlegroups.com> wrote:

Group: http://groups.google.com/group/intro2php-matt-2011-01/topics

    kristin robinson <kayk...@gmail.com> Feb 05 04:29PM -0800 ^
     
    So Evolve and I were looking at code samples taken from the php online
    manual. Here is one example
     
    echo 'You can also have embedded newlines in
    strings this way as it is
    okay to do';
     
    (from page: http://www.php.net/manual/en/language.types.string.php#language.types.string.syntax.single)
     
    We were surprised when looking at involve's code exercise (http://
    codepad.org/udcdHD39) that the Le Guin poem wouldn't render in the
    browser with the embedded newlines. It just runs all together unless
    breaks or returns are manually added. This holds true for single,
    double, heredoc syntax and nowdoc syntax. So where are the embedded
    newlines?
     
    I looked at the source code and the source code had preserved the
    newlines. But since there was no HTML or other instruction to tell
    the browser to preserve the formatting, the newlines are only
    preserved in the source code the PHP is creating.
     
    Matt: is this understanding correct?

     

    Matt Buscemi <ikim...@gmail.com> Feb 05 03:18PM -1000 ^
     
    Kristin,
     
    Yes, this is correct. PHP will output any newlines that you write into a
    string, even if you actually hit return and continue typing on the next
    line. Codepad will even show you the newlines in the output, as in the
    example of your Ursula Le Guin quote. However, the HTML produced by running
    the PHP file is ultimately subjected to the browser, which will ignore
    newlines and only place them where it finds the <br/> tag, or after block
    elements.
     
    Hope this helps!
     
    - Matt
     

     


Reply all
Reply to author
Forward
0 new messages