Annotation of embedaddon/php/ext/standard/tests/strings/sscanf_basic3.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: Test sscanf() function : basic functionality - float 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 float format ***\n";
12:
13: $str = "Part: Widget Length: 111.53 Width: 22.345 Depth: 12.4";
14: $format = "Part: %s Length: %f Width: %f Depth: %f";
15:
16: echo "\n-- Try sccanf() WITHOUT optional args --\n";
17: // extract details using short format
18: list($part, $length, $width, $depth) = sscanf($str, $format);
19: var_dump($part, $length, $width, $depth);
20:
21: echo "\n-- Try sccanf() WITH optional args --\n";
22: // extract details using long format
23: $res = sscanf($str, $format, $part, $length, $width, $depth);
24: var_dump($res, $part, $length, $width, $depth);
25:
26: ?>
27: ===DONE===
28: --EXPECT--
29: *** Testing sscanf() : basic functionality -- using float format ***
30:
31: -- Try sccanf() WITHOUT optional args --
32: string(6) "Widget"
33: float(111.53)
34: float(22.345)
35: float(12.4)
36:
37: -- Try sccanf() WITH optional args --
38: int(4)
39: string(6) "Widget"
40: float(111.53)
41: float(22.345)
42: float(12.4)
43: ===DONE===
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>