Content-Type:text/html フォーマット(書式整形)関数のテスト

※このサンプルの解説は、「CGIの扉」をすべて読み終えてる方を前提としています。

【フォーマット(書式整形)関数のテスト】
◆"abcdefg"
%c =
%s = abcdefg
%10s = abcdefg
%-10s = abcdefg

◆12345.6789
%s = 12345.6789
%d = 12345
%f = 12345.678900
%o = 30071
%x = 3039
%X = 3039
%e = 1.234568e+04
%E = 1.234568E+04
%g = 12345.7
%G = 12345.7

%2d = 12345
%8d = 12345
%08d = 00012345

%2.2f = 12345.68
%8.8f = 12345.67890000
%08f = 12345.678900
%08.f = 00012346
%08.2f = 12345.68
%8.3f% = 12345.679%

%#d = 12345
%#f = 12345.678900
%#o = 030071
%#x = 0x3039
%#X = 0X3039


◆-12345.6789
%s = -12345.6789
%d = -12345
%f = -12345.678900
%o = 1777777777777777747707
%x = ffffffffffffcfc7
%X = FFFFFFFFFFFFCFC7
%e = -1.234568e+04
%E = -1.234568E+04
%g = -12345.7
%G = -12345.7

%2d = -12345
%8d = -12345
%08d = -0012345

%2.2f = -12345.68
%8.8f = -12345.67890000
%08f = -12345.678900
%08.f = -0012346
%08.2f = -12345.68
%8.3f% = -12345.679%

%#d = -12345
%#f = -12345.678900
%#o = 01777777777777777747707
%#x = 0xffffffffffffcfc7
%#X = 0XFFFFFFFFFFFFCFC7


page update:

Copyright (c) 2000-2009, all Rights Reserved & Produced by atom