note 49532 added to function.sprintf

From: Date: Mon, 31 Jan 2005 22:03:08 +0000
Subject: note 49532 added to function.sprintf
Groups: php.notes 
Request: Send a blank email to php-notes+get-84289@lists.php.net to get a copy of this message
Just thought I'd give a heads up for anyone doing cross platform applications. sprintf spacing is different numerically with Windows and Linux. Linux aligned correctly: $ol = sprintf ("%-6s|%11.2f|%11.2f|%11.2f|%11.2f|%11.2f|%11.2f|%11.2f|%11.2f\n", Windows aligned correctly: $ol = sprintf ("%-6s|%14.2f|%14.2f|%14.2f|%14.2f|%14.2f|%14.2f|%14.2f|%14.2f\n", As you can see the strings are fine for spacing, however, the numbers need a difference of 3 in order to have the same amount of spaces. I noticed this after using sprintf to format a header for a web app I was working on. On windows it fit, however, when it came to linux it was MUCH larger than the header. ---- Manual Page -- http://www.php.net/manual/en/function.sprintf.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+49532 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+49532&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+49532&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+49532&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+49532&report=yes&reason=useless Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+49532&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+49532&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#84289) next »