Annotation of embedaddon/php/ext/standard/tests/file/fgetc_variation2.phpt, revision 1.1.1.1

1.1       misho       1: --TEST--
                      2: Test fgetc() function : usage variations - closed handle
                      3: --FILE--
                      4: <?php
                      5: /*
                      6:  Prototype: string fgetc ( resource $handle );
                      7:  Description: Gets character from file pointer
                      8: */
                      9: 
                     10: /* try reading a char using fgetc() using invalid handles
                     11:     - closed file handle
                     12:     - unset file handle
                     13: */
                     14:  
                     15: // include the header for common test function 
                     16: include ("file.inc");
                     17: 
                     18: echo "*** Testing fgetc() : usage variations ***\n";
                     19: 
                     20: echo "-- Testing fgetc() with closed handle --\n";
                     21: // open the file for reading
                     22: $file_handle = fopen(__FILE__, "r");
                     23: // close the file
                     24: fclose($file_handle);
                     25: 
                     26: // read from closed file
                     27: var_dump( fgetc($file_handle) );
                     28: 
                     29: echo "-- Testing fgetc() with unset handle --\n";
                     30: // open the file for reading
                     31: $file_handle = fopen(__FILE__, "r");
                     32: // unset the file handle
                     33: unset($file_handle);
                     34: 
                     35: //fgetc using unset handle
                     36: var_dump( fgetc($file_handle) );
                     37: 
                     38: echo "Done";
                     39: ?>
                     40: --EXPECTF--
                     41: *** Testing fgetc() : usage variations ***
                     42: -- Testing fgetc() with closed handle --
                     43: 
                     44: Warning: fgetc(): %d is not a valid stream resource in %s on line %d
                     45: bool(false)
                     46: -- Testing fgetc() with unset handle --
                     47: 
                     48: Notice: Undefined variable: file_handle in %s on line %d
                     49: 
                     50: Warning: fgetc() expects parameter 1 to be resource, null given in %s on line %d
                     51: bool(false)
                     52: Done

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