From: animaz on
Peter Lind wrote:
> On 23 September 2010 21:47, YAD(YetAnotherDavid) <animaz(a)mail.com> wrote:
>> This code is 95% cut and paste from the PHP manual examples -
>> the Types/Strings/Heredocs section and the Filesystem/fnmatch pages.
>> There are actually two questions here - I have combined the code into one
...

>> Question 1 : how to get the newline functioning ....? even print_r() output
>> is not 'newlined' as it should be. Also note the \n is missing between the "
>> " in the output text of the second test!
>>
>
> Are you outputting to browser or to command line? Browsers have a
> habit of ignoring whitespaces, reducing them to one whitespace
> character regardless of their type or how many.
>
> Regards
> Peter
>

Thanks Peter, - output is to browser, I develop in Notepad++ and
Firefox, and confirm in IE8. But this stuff used to work - I have been
working with PHP for about two years (not pro) and am used to formatting
my output for legibility - especially echoing or var_dumping variables
when still testing the code. So the failure is recent and I just can't
figure what changed.
David
From: Peter Lind on
On 24 September 2010 12:49, YAD(YetAnotherDavid) <animaz(a)mail.com> wrote:
> Peter Lind wrote:
>>
>> On 23 September 2010 21:47, YAD(YetAnotherDavid) <animaz(a)mail.com> wrote:
>>>
>>> This code is 95% cut and paste from the PHP manual examples -
>>> the Types/Strings/Heredocs section and the Filesystem/fnmatch pages.
>>> There are actually two questions here - I have combined the code into one
>
>  ...
>
>>> Question 1 : how to get the newline functioning ....? even print_r()
>>> output
>>> is not 'newlined' as it should be. Also note the \n is missing between
>>> the "
>>> " in the output text of the second test!
>>>
>>
>> Are you outputting to browser or to command line? Browsers have a
>> habit of ignoring whitespaces, reducing them to one whitespace
>> character regardless of their type or how many.
>>
>> Regards
>> Peter
>>
>
> Thanks Peter, - output is to browser, I develop in Notepad++ and Firefox,
> and confirm in IE8. But this stuff used to work - I have been working with
> PHP for about two years (not pro) and am used to formatting my output for
> legibility - especially echoing or var_dumping variables when still testing
> the code. So the failure is recent and I just can't figure what changed.
> David

Browsers treat newlines as any other whitespace - so print_r and
var_dump will not, on their own, provide you with a linebreak in a
browser. If you've got xdebug installed, var_dump will provide a nicer
output (including line-breaks).
However, by far the easiest way to check if you're actually getting
linebreaks in your output is checking the source.

If you're suddenly experiencing a change in output, then some of your
environment variables have changed - hard to say which one without
knowing more about your system, but you must obviously have
changed/updated something for this to happen.

Regards
Peter

--
<hype>
WWW: http://plphp.dk / http://plind.dk
LinkedIn: http://www.linkedin.com/in/plind
BeWelcome/Couchsurfing: Fake51
Twitter: http://twitter.com/kafe15
</hype>