I see the terms "file pointer" and "file handle" used a lot in the same context. Are these two terms 100% interchangeable, or is there some subtle difference in meaning?
Thanks,
Drew
file pointer / file handle
Moderator: General Moderators
Re: file pointer / file handle
Hey Drew,
There is a difference between the two. I have tried to explain them both for you below:
File Pointer
This is the position or pointer of where you are currently reading or working in a file.
File Handle
Is a reference to the actual file that you are currently working with.
Hope this helps
There is a difference between the two. I have tried to explain them both for you below:
File Pointer
This is the position or pointer of where you are currently reading or working in a file.
File Handle
Is a reference to the actual file that you are currently working with.
Hope this helps
Re: file pointer / file handle
That distinction makes sense, but is it typically observed? Even in the php manual, it seems file pointer and file handle are used interchangeably in discussing fopen(), fwrite(), fclose(), etc. Is this a distinction that is typically treated carelessly, or am I missing something?
Cheers,
Drew
Cheers,
Drew
Re: file pointer / file handle
Actually in PHP there is no distinction between the two. A file handle is a pointer referencing a file stream (it might not even be a physical file, could be just a memory allocation). It will always point to the current position in the stream, and can be traversed using functions like fseek() and rewind().