sscanf_basic7.phpt 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. --TEST--
  2. Test sscanf() function : basic functionality - octal format
  3. --FILE--
  4. <?php
  5. /* Prototype : mixed sscanf ( string $str , string $format [, mixed &$... ] )
  6. * Description: Parses input from a string according to a format
  7. * Source code: ext/standard/string.c
  8. */
  9. echo "*** Testing sscanf() : basic functionality - using octal format ***\n";
  10. $str = "0123 -0123 +0123 0129 -0129 +0129";
  11. $format = "%o %o %o %o %o %o";
  12. echo "\n-- Try sccanf() WITHOUT optional args --\n";
  13. // extract details using short format
  14. list($arg1, $arg2, $arg3, $arg4, $arg5, $arg6) = sscanf($str, $format);
  15. var_dump($arg1, $arg2, $arg3, $arg4, $arg5, $arg6);
  16. echo "\n-- Try sccanf() WITH optional args --\n";
  17. // extract details using long format
  18. $res = sscanf($str, $format, $arg1, $arg2, $arg3, $arg4, $arg5, $arg6);
  19. var_dump($res, $arg1, $arg2, $arg3, $arg4, $arg5, $arg6);
  20. ?>
  21. ===DONE===
  22. --EXPECT--
  23. *** Testing sscanf() : basic functionality - using octal format ***
  24. -- Try sccanf() WITHOUT optional args --
  25. int(83)
  26. int(-83)
  27. int(83)
  28. int(10)
  29. NULL
  30. NULL
  31. -- Try sccanf() WITH optional args --
  32. int(4)
  33. int(83)
  34. int(-83)
  35. int(83)
  36. int(10)
  37. NULL
  38. NULL
  39. ===DONE===