php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #6149 Print does not format output correctly
Submitted: 2000-08-14 11:02 UTC Modified: 2000-08-14 11:08 UTC
From: tim at timcrider dot com Assigned:
Status: Closed Package: Scripting Engine problem
PHP Version: 4.0.1pl2 OS: Solaris 2.7 SPARC
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: tim at timcrider dot com
New email:
PHP Version: OS:

 

 [2000-08-14 11:02 UTC] tim at timcrider dot com
PHP CONFIGURE INFO:
'./configure' '--with-apache=../apache_1.3.12' '--without-gd' '--with-mysql' '--disable-debug' '--enable-track-vars'

OS INFO:
SunOS dev0.pgh.directstuff.com 5.7 Generic_106541-11 sun4u sparc SUNW,Ultra-60

--- BUG DESCRIPTION ---
When I use a for loop to display results taken from a function, the format is not correct. Here the script that reproduces the error:

<?
function what_is_j($i) {
  $j = $i + 2;  
  print "($j)";
}
for ($i = 0; $i < 10; $i++) {
    print "$i - " . what_is_j($i) . "\n";    
}
?>
The output should look like:
0 - (0)
1 - (2)
2 - (4)
...
However the output looks like:
(2)0 - 
(3)1 - 
(4)2 - 
(5)3 - 
(6)4 - 
(7)5 - 
(8)6 - 
(9)7 - 
(10)8 - 
(11)9 - 

If you need any further information please email me @ tim@timcrider.com.

   Tim Crider

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2000-08-14 11:08 UTC] stas@php.net
Your script is buggy. what_is_j prints before main loop print.
 
PHP Copyright © 2001-2026 The PHP Group
All rights reserved.
Last updated: Sun Oct 11 10:00:01 2026 UTC