473,405 Members | 2,300 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

PHP 5.0.0RC3 output buffering bug?

A question about Output Buffering in PHP-CLI.

Is it expected that the following code will emit two representations of $x?

I would like to use print_r(), but capature its output in a String, to use
ain a generic logging infrastructure. But every call to print_r(),
var_dump(), var_export(), et. al. goes to STDOUT no matter what I do?

How to I get print_r() to return a string, and not go to STDOUT?

Platform: php-5.0.0RC3 CLI configured/compiled/installed via FreeBSD 5.2.1 ports.
<?php

$x = array('this', 'that', 'the other thing');

ob_start();
print_r($x);
$result = ob_get_flush();

print "$result\n";

?>

--
Mark Evenson <ev*****@panix.com>

"A screaming comes across the sky. It has happened before, but there is
nothing to compare to it now."
Jul 17 '05 #1
2 1701
Mark Evenson wrote:
A question about Output Buffering in PHP-CLI.

Is it expected that the following code will emit two representations
of $x?

I would like to use print_r(), but capature its output in a String,
to use
ain a generic logging infrastructure. But every call to print_r(),
var_dump(), var_export(), et. al. goes to STDOUT no matter what I do?

How to I get print_r() to return a string, and not go to STDOUT?


print_r($array, true);

Berislav

--
If the Internet is a Marx Brothers movie, and Web, e-mail, and IRC are
Groucho, Chico, and Harpo, then Usenet is Zeppo.
Jul 17 '05 #2
"Berislav Lopac" <be************@dimedia.hr> writes:
Mark Evenson wrote:

[...]
How to I get print_r() to return a string, and not go to STDOUT?


print_r($array, true);


Alright. Works! Sorry I missed that in the documentation.

Thanks for your help.

--
Mark Evenson <ev*****@panix.com>

"A screaming comes across the sky. It has happened before, but there is
nothing to compare to it now."
Jul 17 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: vishal | last post by:
hi vishal here. can anyone tell me that how to buffer output and then send the output to client at a time. what is my problem is that i have a php file which runs query on database and takes...
0
by: Alexander DEJANOVSKI | last post by:
JyRetic 1.0RC3 was just released. (http://retic.sourceforge.net) Changes are (I might have forgotten some bug fixes): - Bug fix : Scheduled events didn't work if no parameter file was required...
1
by: Tim Mohler | last post by:
All - I have a script that provides a web page interface to various system utilities. Once the user has selected the utility and input various parameters, it calls itself with a different method...
9
by: Fred Ma | last post by:
Hello, I posted previously under the thread: How to break this up into streambuf/ostream I've asked our library to get "C++ IOStreams and Locales..." by A. Langer et al. Meantime, I've...
15
by: jools | last post by:
I'm having trouble modifying some code written by someone else. The code is very dense and obscure but does work fine. However I need to insert a block of my own and I've hit what I assume is a...
4
by: Grant Edwards | last post by:
When I ssh in to my Windows XP box and run Python apps, output from "print" and and "sys.stdout.write()" is being buffered so that none of the output shows up until the program exits. From...
25
by: Abubakar | last post by:
Hi, recently some C programmer told me that using fwrite/fopen functions are not efficient because the output that they do to the file is actually buffered and gets late in writing. Is that...
5
by: thedsadude | last post by:
Hello, I'm launching a script as follows: <code> p = subprocess.Popen() p.wait() </code> If p.py writes to sys.stdout, then it is shown on the console.
1
by: coolsti | last post by:
I am having a curious problem with Vista working on a Lenovo thinkpad. To test and demonstrate this problem, I have a PHP script that does not terminate. It enters an infinite loop where it...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.