php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #14669 print_r inconsistancy with newlines
Submitted: 2001-12-23 08:25 UTC Modified: 2002-07-07 13:01 UTC
From: sander@php.net Assigned:
Status: Wont fix Package: Variables related
PHP Version: 4.1.0 OS: Debian Linux, Win2K
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please — but make sure to vote on the bug!
Your email address:
MUST BE VALID
Solve the problem:
18 + 28 = ?
Subscribe to this entry?

 
 [2001-12-23 08:25 UTC] sander@php.net
print_r ends with a newline if you print_r() an array, but not if you print_r() a string or number:

$foo="abc";
$bar=123;
echo "-";
print_r($foo);
echo "-";
print_r($bar);
echo "-";

Ouput: -abc-123-


$foo=array(123, "abc");
echo "-";
print_r($foo);
echo "-";

Output: 
-Array
(
    [0] => 123
    [1] => abc
)
-

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-07-07 13:01 UTC] derick@php.net
print_r is a debugging tool, and I don't see any reason why this behavior should bother anybody. Changing status to "Won't fix".

Derick
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 25 00:01:41 2024 UTC