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
 [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

Add a Patch

Pull Requests

Add a Pull Request

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-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 19 15:01:28 2024 UTC