Edit report at https://bugs.php.net/bug.php?id=64889&edit=1
ID: 64889 Updated by: ar...@php.net Reported by: xoneca+phpbugs at gmail dot com Summary: printf inconsistent parsing format string -Status: Open +Status: Not a bug Type: Bug Package: Scripting Engine problem Operating System: Linux 2.6.32-46-generic PHP Version: 5.4.15 Block user comment: N Private report: N New Comment: As documented, use %% to represent a literal % in the format string. Previous Comments: ------------------------------------------------------------------------ [2013-05-21 16:01:46] xoneca+phpbugs at gmail dot com Tested on latest stable and the result was the same. ------------------------------------------------------------------------ [2013-05-21 15:21:33] xoneca+phpbugs at gmail dot com Description: ------------ `printf` is inconsistent parsing the format string. Sometimes it throws a warning, and sometimes does not. `printf` doesn't seem to like very much single `%` chars and gets crazy. Depending on the arguments number, it will print something, or nothing. Test script: --------------- printf( '% % % %'); // or echo sprintf(...); printf( '% % % %', 10); printf( '% % % %', 10, 20); printf( '% % % %', 10, 20, 30); printf( '% % % %', 10, 20, 30, 40); printf( '% % % %', 10, 20, 30, 40, 50); // Another example: printf( '% ## %d ## % ## %d ## %d', 10, 20, 30, 40, 50); Expected result: ---------------- Throwing a warning at each call, or none at all. But not only sometimes. Actual result: -------------- php > printf( '% % % %'); PHP Warning: printf(): Too few arguments in php shell code on line 1 php > printf( '% % % %', 10); PHP Warning: printf(): Too few arguments in php shell code on line 1 php > printf( '% % % %', 10, 20); % % php > printf( '% % % %', 10, 20, 30); % % php > printf( '% % % %', 10, 20, 30, 40); % % php > printf( '% % % %', 10, 20, 30, 40, 50); % % php > // Another example: php > echo sprintf( '% ## %d ## % ## %d ## %d', 10, 20, 30, 40, 50); # 20 ## # 40 ## 50 ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=64889&edit=1