php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #10584 flush() in functions - behaviour wrong?
Submitted: 2001-05-01 14:21 UTC Modified: 2001-05-01 14:52 UTC
From: hara at oderwat dot de Assigned:
Status: Closed Package: Scripting Engine problem
PHP Version: 4.0.5 OS: Linux SuSE 6.3 - Apache
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: hara at oderwat dot de
New email:
PHP Version: OS:

 

 [2001-05-01 14:21 UTC] hara at oderwat dot de
<?php
function test() {
	print("1");
	flush();
}
print("0".test());
?>

RESULT: 10

I think thats wrong!

- Hans

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2001-05-01 14:46 UTC] cmv@php.net
Well, I would say it's counter-intuitive perhaps, but not wrong. :)

Think of it like a math expression, with parenthesis defining precedence:

             evaluated first
                  vvvv

    print( "0" . test() );

         ^              ^
         evaluated second

So the test() gets evaluated first which does it's flush(), then the rest.

(Besides, test() doesn't return anything, so printing it's result is probably wrong anyway.)

- Colin
 [2001-05-01 14:52 UTC] hholzgra@php.net
what you want to do is
return("1") instead of print("1")
in test()

 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Tue May 06 02:01:28 2025 UTC