sscanf_basic6.phpt 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. --TEST--
  2. Test sscanf() function : basic functionality - unsigned format
  3. --SKIPIF--
  4. <?php
  5. if (PHP_INT_SIZE != 4) {
  6. die("skip this test is for 32bit platform only");
  7. }
  8. ?>
  9. --FILE--
  10. <?php
  11. /* Prototype : mixed sscanf ( string $str , string $format [, mixed &$... ] )
  12. * Description: Parses input from a string according to a format
  13. * Source code: ext/standard/string.c
  14. */
  15. echo "*** Testing sscanf() : basic functionality - using unsigned format ***\n";
  16. $str = "-11 +11 11 -11.234 +11.234 11.234";
  17. $format = "%u %u %u %u %u %u";
  18. echo "\n-- Try sccanf() WITHOUT optional args --\n";
  19. // extract details using short format
  20. list($arg1, $arg2, $arg3, $arg4, $arg5, $arg6) = sscanf($str, $format);
  21. var_dump($arg1, $arg2, $arg3, $arg4, $arg5, $arg6);
  22. echo "\n-- Try sccanf() WITH optional args --\n";
  23. // extract details using long format
  24. $res = sscanf($str, $format, $arg1, $arg2, $arg3, $arg4, $arg5, $arg6);
  25. var_dump($res, $arg1, $arg2, $arg3, $arg4, $arg5, $arg6);
  26. ?>
  27. ===DONE===
  28. --EXPECT--
  29. *** Testing sscanf() : basic functionality - using unsigned format ***
  30. -- Try sccanf() WITHOUT optional args --
  31. string(10) "4294967285"
  32. int(11)
  33. int(11)
  34. string(10) "4294967285"
  35. NULL
  36. NULL
  37. -- Try sccanf() WITH optional args --
  38. int(4)
  39. string(10) "4294967285"
  40. int(11)
  41. int(11)
  42. string(10) "4294967285"
  43. NULL
  44. NULL
  45. ===DONE===