|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2004-06-17 00:11 UTC] chris at arbo-com dot fr
Description:
------------
when use printf with <?=printf
the output is not identical at older version of php
Now the printf send the true string, but add after the nombre of send caractere.
the documentation of printf retur void et not the nombre of caractere send.
Reproduce code:
---------------
<?
for($i=0; $i<=4; $i++)
{
?>
my line <?=printf("%02d<br>",$i) ?>
<?php
}
?>
Expected result:
----------------
with old version printf not send nombre of caractere write on flux.
Actual result:
--------------
my line 00
6my line 01
6my line 02
6my line 03
6my line 04
6
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Dec 13 12:00:01 2025 UTC |
True. Printf changed behavior, now it seems to return result string length (instead of void). But I think there is also a bug in your code: <?=printf("%02d<br>",$i)?> ^^ You could try: <?=sprintf("%02d<br>",$i)?> or: <?printf("%02d<br>",$i);?> Because <?='string'?> echoes 'string' This means that it will echo the return of printf. When it was void, there was no visual problem.