Annotation of embedaddon/php/ext/standard/tests/strings/sscanf_basic5.phpt, revision 1.1
1.1 ! misho 1: --TEST--
! 2: Test sscanf() function : basic functionality - exponential 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 exponential format ***\n";
! 12:
! 13: $str = "10.12345 10.12345E3 10.12345e3 -10.12345e4" ;
! 14: $format1 = "%e %e %e %e";
! 15: $format2 = "%E %E %E %E";
! 16:
! 17: echo "\n-- Try sccanf() WITHOUT optional args --\n";
! 18: // extract details using short format
! 19: list($arg1, $arg2, $arg3, $arg4) = sscanf($str, $format1);
! 20: var_dump($arg1, $arg2, $arg3, $arg4);
! 21: list($arg1, $arg2, $arg3, $arg4) = sscanf($str, $format2);
! 22: var_dump($arg1, $arg2, $arg3, $arg4);
! 23:
! 24: echo "\n-- Try sccanf() WITH optional args --\n";
! 25: // extract details using long format
! 26: $res = sscanf($str, $format1, $arg1, $arg2, $arg3, $arg4);
! 27: var_dump($res, $arg1, $arg2, $arg3, $arg4);
! 28: $res = sscanf($str, $format2,$arg1, $arg2, $arg3, $arg4);
! 29: var_dump($res, $arg1, $arg2, $arg3, $arg4);
! 30:
! 31:
! 32: ?>
! 33: ===DONE===
! 34: --EXPECT--
! 35: *** Testing sscanf() : basic functionality -using exponential format ***
! 36:
! 37: -- Try sccanf() WITHOUT optional args --
! 38: float(10.12345)
! 39: float(10123.45)
! 40: float(10123.45)
! 41: float(-101234.5)
! 42: float(10.12345)
! 43: float(10123.45)
! 44: float(10123.45)
! 45: float(-101234.5)
! 46:
! 47: -- Try sccanf() WITH optional args --
! 48: int(4)
! 49: float(10.12345)
! 50: float(10123.45)
! 51: float(10123.45)
! 52: float(-101234.5)
! 53: int(4)
! 54: float(10.12345)
! 55: float(10123.45)
! 56: float(10123.45)
! 57: float(-101234.5)
! 58: ===DONE===
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>