Jump to content

Recommended Posts

After switching from PHP 5.3 on Windows Server 2003 to PHP 7.4.3 on Linux Mint 19.3 (Tricia Cinnamon), I find that the output of print_r() has changed.

If we look at the documentation (https://www.php.net/manual/en/function.print-r.php), the provided example output is as it was on my earlier machine:

<pre>
Array
(
    [a] => apple
    [b] => banana
    [c] => Array
        (
            [0] => x
            [1] => y
            [2] => z
        )
)
</pre>

However, on the second machine, the output is:

<pre>
Array
(
    [a] => apple
    [b] => banana
    [c] => Array
        (
            [0] => x
            [1] => y
            [2] => z
        )
<blank line>
)
</pre>

Note the unexpected new line after each recursed array's closing parenthesis. The new line is not present after the outermost array closing parenthesis.

Also to note, there is a newer version of XDebug installed.

My question is: Is this a bug? (Follow-on question: if possible to determine at which version the output changed, what version would that be?)

This difference is causing existing code to not be able to correctly parse that output.

Link to comment
https://forums.phpfreaks.com/topic/310613-print_r-output-changed/
Share on other sites

I wouldn't know what to look for when searching PHP's bug tracking system.

That's why I asked here - maybe there is someone here who is far, far more into understanding the innards of PHP who could definitely say the extra line endings is a bug, and whether or not it is even directly associated with print_r(), or if the extra line endings were coded into the PHP source elsewhere and its appearance in print_r() is a knock-on effect.

 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.