Annotation of embedaddon/php/ext/standard/tests/file/fscanf.phpt, revision 1.1
1.1 ! misho 1: --TEST--
! 2: fscanf() tests
! 3: --FILE--
! 4: <?php
! 5:
! 6: $filename = dirname(__FILE__)."/fscanf.dat";
! 7:
! 8: var_dump(fscanf());
! 9: var_dump(fscanf(array()));
! 10: var_dump(fscanf(array(), array(), new stdclass));
! 11:
! 12: file_put_contents($filename, "data");
! 13:
! 14: $fp = fopen($filename, "rt");
! 15: var_dump(fscanf($fp, "%d", $v));
! 16: var_dump($v);
! 17: fclose($fp);
! 18:
! 19: $fp = fopen($filename, "rt");
! 20: var_dump(fscanf($fp, "%s", $v));
! 21: var_dump($v);
! 22: fclose($fp);
! 23:
! 24: $fp = fopen($filename, "rt");
! 25: var_dump(fscanf($fp, "%s", $v, $v1));
! 26: var_dump($v);
! 27: var_dump($v1);
! 28: fclose($fp);
! 29:
! 30: $v = array();
! 31: $v1 = array();
! 32: $fp = fopen($filename, "rt");
! 33: var_dump(fscanf($fp, "", $v, $v1));
! 34: var_dump($v);
! 35: var_dump($v1);
! 36: fclose($fp);
! 37:
! 38: $v = array();
! 39: $v1 = array();
! 40: $fp = fopen($filename, "rt");
! 41: var_dump(fscanf($fp, "%.a", $v, $v1));
! 42: var_dump($v);
! 43: var_dump($v1);
! 44: fclose($fp);
! 45:
! 46: @unlink($filename);
! 47: touch($filename);
! 48:
! 49: $fp = fopen($filename, "rt");
! 50: var_dump(fscanf($fp, "%s", $v));
! 51: var_dump($v);
! 52: fclose($fp);
! 53:
! 54: file_put_contents($filename, "data");
! 55:
! 56: $fp = fopen($filename, "rt");
! 57: var_dump(fscanf($fp, "%s%d", $v));
! 58:
! 59: @unlink($filename);
! 60: echo "Done\n";
! 61: ?>
! 62: --EXPECTF--
! 63: Warning: fscanf() expects at least 2 parameters, 0 given in %s on line %d
! 64: NULL
! 65:
! 66: Warning: fscanf() expects at least 2 parameters, 1 given in %s on line %d
! 67: NULL
! 68:
! 69: Warning: fscanf() expects parameter 1 to be resource, array given in %s on line %d
! 70: NULL
! 71: int(0)
! 72: NULL
! 73: int(1)
! 74: string(4) "data"
! 75:
! 76: Warning: fscanf(): Variable is not assigned by any conversion specifiers in %s on line %d
! 77: int(-1)
! 78: string(4) "data"
! 79: NULL
! 80:
! 81: Warning: fscanf(): Variable is not assigned by any conversion specifiers in %s on line %d
! 82: int(-1)
! 83: array(0) {
! 84: }
! 85: array(0) {
! 86: }
! 87:
! 88: Warning: fscanf(): Bad scan conversion character "." in %s on line %d
! 89: int(-1)
! 90: array(0) {
! 91: }
! 92: array(0) {
! 93: }
! 94: bool(false)
! 95: array(0) {
! 96: }
! 97:
! 98: Warning: fscanf(): Different numbers of variable names and field specifiers in %s on line %d
! 99: int(-1)
! 100: Done
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>