printf_basic3.phpt 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. --TEST--
  2. Test printf() function : basic functionality - float format
  3. --FILE--
  4. <?php
  5. echo "*** Testing printf() : basic functionality - using float format ***\n";
  6. // Initialise all required variables
  7. $format = "format";
  8. $format1 = "%f";
  9. $format2 = "%f %f";
  10. $format3 = "%f %f %f";
  11. $format11 = "%F";
  12. $format22 = "%F %F";
  13. $format33 = "%F %F %F";
  14. $arg1 = 11.11;
  15. $arg2 = 22.22;
  16. $arg3 = 33.33;
  17. echo "\n-- Calling printf() with no arguments--\n";
  18. $result = printf($format);
  19. echo "\n";
  20. var_dump($result);
  21. echo "\n-- Calling printf() with one arguments--\n";
  22. $result = printf($format1, $arg1);
  23. echo "\n";
  24. var_dump($result);
  25. $result = printf($format11, $arg1);
  26. echo "\n";
  27. var_dump($result);
  28. echo "\n-- Calling printf() with two arguments--\n";
  29. $result = printf($format2, $arg1, $arg2);
  30. echo "\n";
  31. var_dump($result);
  32. $result = printf($format22, $arg1, $arg2);
  33. echo "\n";
  34. var_dump($result);
  35. echo "\n-- Calling printf() with three arguments--\n";
  36. $result = printf($format3, $arg1, $arg2, $arg3);
  37. echo "\n";
  38. var_dump($result);
  39. $result = printf($format33, $arg1, $arg2, $arg3);
  40. echo "\n";
  41. var_dump($result);
  42. ?>
  43. --EXPECT--
  44. *** Testing printf() : basic functionality - using float format ***
  45. -- Calling printf() with no arguments--
  46. format
  47. int(6)
  48. -- Calling printf() with one arguments--
  49. 11.110000
  50. int(9)
  51. 11.110000
  52. int(9)
  53. -- Calling printf() with two arguments--
  54. 11.110000 22.220000
  55. int(19)
  56. 11.110000 22.220000
  57. int(19)
  58. -- Calling printf() with three arguments--
  59. 11.110000 22.220000 33.330000
  60. int(29)
  61. 11.110000 22.220000 33.330000
  62. int(29)