????JFIF??x?x????'
Server IP : 79.136.114.73 / Your IP : 216.73.216.86 Web Server : Apache/2.4.7 (Ubuntu) PHP/5.5.9-1ubuntu4.29 OpenSSL/1.0.1f System : Linux b8009 3.13.0-170-generic #220-Ubuntu SMP Thu May 9 12:40:49 UTC 2019 x86_64 User : www-data ( 33) PHP Version : 5.5.9-1ubuntu4.29 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority, MySQL : ON | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /proc/self/root/home/b8009/php-5.6.22/ext/standard/tests/file/ |
Upload File : |
--TEST-- Test feof() function : basic functionality --CREDITS-- Dave Kelsey <d_kelsey@uk.ibm.com> --FILE-- <?php /* Prototype : proto bool feof(resource fp) * Description: Test for end-of-file on a file pointer * Source code: ext/standard/file.c * Alias to functions: gzeof */ echo "*** Testing feof() : basic functionality ***\n"; $tmpFile1 = __FILE__.".tmp1"; $h = fopen($tmpFile1, 'wb'); $count = 10; for ($i = 1; $i <= $count; $i++) { fwrite($h, "some data $i\n"); } fclose($h); echo "\n*** testing reading complete file using feof to stop ***\n"; $h = fopen($tmpFile1, 'rb'); //feof is not set to true until you try to read past the end of file. //so fgets will be called even if we are at the end of the file on //last time to set the eof flag but it will fail to read. $lastline = ""; while (!feof($h)) { $previousLine = $lastline; $lastline = fgets($h); } echo $previousLine; var_dump($lastline); // this should be false fclose($h); $tmpFile2 = __FILE__.".tmp2"; $h = fopen($tmpFile2, 'wb+'); $count = 10; echo "*** writing $count lines, testing feof ***\n"; for ($i = 1; $i <=$count; $i++) { fwrite($h, "some data $i\n"); var_dump(feof($h)); } echo "*** testing feof on unclosed file after a read ***\n"; fread($h, 100); var_dump(feof($h)); $eofPointer = ftell($h); echo "*** testing feof after a seek to near the beginning ***\n"; fseek($h, 20, SEEK_SET); var_dump(feof($h)); echo "*** testing feof after a seek to end ***\n"; fseek($h, $eofPointer, SEEK_SET); var_dump(feof($h)); echo "*** testing feof after a seek passed the end ***\n"; fseek($h, $eofPointer + 1000, SEEK_SET); var_dump(feof($h)); echo "*** closing file, testing eof ***\n"; fclose($h); feof($h); unlink($tmpFile1); unlink($tmpFile2); echo "Done"; ?> --EXPECTF-- *** Testing feof() : basic functionality *** *** testing reading complete file using feof to stop *** some data 10 bool(false) *** writing 10 lines, testing feof *** bool(false) bool(false) bool(false) bool(false) bool(false) bool(false) bool(false) bool(false) bool(false) bool(false) *** testing feof on unclosed file after a read *** bool(true) *** testing feof after a seek to near the beginning *** bool(false) *** testing feof after a seek to end *** bool(false) *** testing feof after a seek passed the end *** bool(false) *** closing file, testing eof *** Warning: feof(): %d is not a valid stream resource in %s on line %d Done