|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #106 output from functions printed in wrong order
Submitted: 1998-02-26 00:35 UTC Modified: 1998-02-26 00:52 UTC
From: eric at generation-i dot com Assigned: rasmus (profile)
Status: Closed Package: Parser error
PHP Version: 3.0 Latest CVS OS: linux 2.0.33
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: eric at generation-i dot com
New email:
PHP Version: OS:


 [1998-02-26 00:35 UTC] eric at generation-i dot com
cfunction test()
  echo "-middle-";

<?echo "begin".test()."end<br>\n"?>
echo "begin".$testvar."end<br>\n";
echo "begin".$testvar."end<br>\n"

The output from the above is:


The first and the last one are as expected but the two in the
middle are not.


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [1998-02-26 00:52 UTC] rasmus
In order for the 'echo "begin".test()."end"' line to work as you expect,
your test function should do a 'return "-middle-"' instead of echoing it
directly.  The behaviour you are seeing is exactly what I would expect.
The function needs to be called before other output can occur on that
line.  For example, what if your script was:

  if(test()) {
      echo "Hello";

Obviously the test() function needs to be called before the if condition
can be evaluated.  Same goes for your echo expression.  The functions
within the echo expression are called before the echo mechanism prints
anything out.  By having those functions display things directly you force
this to be shown before the rest of the output.
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Jun 14 20:01:31 2024 UTC