printf_basic3.phpt 1.7 KB

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