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