Annotation of embedaddon/php/ext/standard/tests/strings/sscanf_basic1.phpt, revision 1.1.1.1

1.1       misho       1: --TEST--
                      2: Test sscanf() function : basic functionality - string 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: 
                     10: /*
                     11:  * Testing sscanf() : basic functionality
                     12: */
                     13: 
                     14: echo "*** Testing sscanf() : basic functionality - using string format ***\n";
                     15: 
                     16: $str = "Part: Widget Serial Number: 1234789 Stock: 25";
                     17: $format = "Part: %s Serial Number: %s Stock: %s";
                     18: 
                     19: echo "\n-- Try sccanf() WITHOUT optional args --\n"; 
                     20: // extract details using short format
                     21: list($part, $number, $stock) = sscanf($str, $format);
                     22: var_dump($part, $number, $stock);
                     23: 
                     24: echo "\n-- Try sccanf() WITH optional args --\n"; 
                     25: // extract details using long  format
                     26: $res = sscanf($str, $format, $part, $number, $stock);
                     27: var_dump($res, $part, $number, $stock); 
                     28: 
                     29: ?>
                     30: ===DONE===
                     31: --EXPECT--
                     32: *** Testing sscanf() : basic functionality - using string format ***
                     33: 
                     34: -- Try sccanf() WITHOUT optional args --
                     35: string(6) "Widget"
                     36: string(7) "1234789"
                     37: string(2) "25"
                     38: 
                     39: -- Try sccanf() WITH optional args --
                     40: int(3)
                     41: string(6) "Widget"
                     42: string(7) "1234789"
                     43: string(2) "25"
                     44: ===DONE===

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>