sscanf_basic7.phpt 931 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. --TEST--
  2. Test sscanf() function : basic functionality - octal format
  3. --FILE--
  4. <?php
  5. echo "*** Testing sscanf() : basic functionality - using octal format ***\n";
  6. $str = "0123 -0123 +0123 0129 -0129 +0129";
  7. $format = "%o %o %o %o %o %o";
  8. echo "\n-- Try sccanf() WITHOUT optional args --\n";
  9. // extract details using short format
  10. list($arg1, $arg2, $arg3, $arg4, $arg5, $arg6) = sscanf($str, $format);
  11. var_dump($arg1, $arg2, $arg3, $arg4, $arg5, $arg6);
  12. echo "\n-- Try sccanf() WITH optional args --\n";
  13. // extract details using long format
  14. $res = sscanf($str, $format, $arg1, $arg2, $arg3, $arg4, $arg5, $arg6);
  15. var_dump($res, $arg1, $arg2, $arg3, $arg4, $arg5, $arg6);
  16. ?>
  17. --EXPECT--
  18. *** Testing sscanf() : basic functionality - using octal format ***
  19. -- Try sccanf() WITHOUT optional args --
  20. int(83)
  21. int(-83)
  22. int(83)
  23. int(10)
  24. NULL
  25. NULL
  26. -- Try sccanf() WITH optional args --
  27. int(4)
  28. int(83)
  29. int(-83)
  30. int(83)
  31. int(10)
  32. NULL
  33. NULL