php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #25977 fopen('file', 'r'); doesn't move to the end of the file
Submitted: 2003-10-24 12:52 UTC Modified: 2003-10-30 21:01 UTC
From: nightstorm at tlen dot pl Assigned:
Status: Not a bug Package: Filesystem function related
PHP Version: 5CVS-2003-10-24 (dev) OS: Windows XP
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: nightstorm at tlen dot pl
New email:
PHP Version: OS:

 

 [2003-10-24 12:52 UTC] nightstorm at tlen dot pl
Description:
------------
I tried to write something like a simple package system, which loads the files into an array, serializes it, and compresses. But I noticed that each file didn't have first 334 characters. I wrote a simple code to check it and I stated this is a PHP bug. I experimented with many variants - changing the way of loading (file_get_contents(), file() etc.), using fseek($fp, 0, SEEK_SET); and also moving to the other directory, or loading other files. There is the funniest part of this story. I've got a template system, which loads templates also by fopen(), but I noticed that these files are not cutted. I copied some code from parser and set it to open a file in main project directory ( / ) - it was cutted. Then i checked with files form /templates - these aren't cutted. I checked phpBB 2 - also: files from /templates weren't cutted, but from other directories, and the root - were. And only for these files, which were created there. So if I copied any file from for example root to /templates, it wouldn't work. I looked into "file attributes" and everything was the same in each file: read only on, archivization off, indexing on. I totally don't know, what's going on. fseek($fp, 0, SEEK_SET); should set the beginning of the file, but it is moving me into 334th character; fseek($fp, 1, SEEK_SET); works correctly. rewind($fp) also doesn't work. ftell($fp); returns 0.

System:
Windows XP Pro, NTFS partition
Apache 2.0.4
PHP 5.0.0-dev latest snapshot

Reproduce code:
---------------
$f = fopen('../../engine/fws.php', 'r');
echo '<pre>';
while(!feof($f)){
	echo fread($f, 256);
}
fclose($f);
echo '</pre>';
	

Expected result:
----------------
<?php
/*
*****************************************************************************
*           Fillar WebSystem 1.0.0
*   ========================================
*         Fillar Systems 2002/2003
*       Site Engine/Discussion Board
*****************************************************************************
*
*   -> Main interface
*   -> Written by Tomasz "Zyx" J?drzejewski
*   -> Date started: 1-7-2003
*
*	-> Version: 1.0.0
*****************************************************************************
*/
/***************************************************************************
 *
 *   This program is free software; you can redistribute it and/or modify
 *   it under the terms of the GNU General Public License as published by
 *   the Free Software Foundation; either version 2 of the License, or
 *   (at your option) any later version.
 *
 ***************************************************************************/
....

Actual result:
--------------
 Main interface
*   -> Written by Tomasz "Zyx" J?drzejewski
*   -> Date started: 1-7-2003
*
*	-> Version: 1.0.0
*****************************************************************************
*/
/***************************************************************************
 *
 *   This program is free software; you can redistribute it and/or modify
 *   it under the terms of the GNU General Public License as published by
 *   the Free Software Foundation; either version 2 of the License, or
 *   (at your option) any later version.
 *
 ***************************************************************************/
 ....

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-10-30 21:01 UTC] sniper@php.net
fopen ('file', 'rb');

 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Thu Sep 18 05:00:01 2025 UTC