|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #79389 ftell retruns false on linux for STDIN
Submitted: 2020-03-17 14:00 UTC Modified: 2020-03-18 08:06 UTC
From: mail at ahmd dot io Assigned:
Status: Verified Package: Streams related
PHP Version: 7.4.3 OS: linux
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: mail at ahmd dot io
New email:
PHP Version: OS:


 [2020-03-17 14:00 UTC] mail at ahmd dot io

ftell php function returns false for STDIN on Linux with all php 7.4 versions

The related commit seems to be this one

Test script:

Expected result:

Actual result:


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2020-03-17 18:28 UTC]
-Assigned To: +Assigned To: nikic
 [2020-03-17 18:28 UTC]
Well, the behavior depends on which kind of file stdin refers to.
If it is a pipe, the PHP 7.4 behavior makes more sense to me.
Anyhow, the mentioned commit is not the cause of that behavioral
change (it is not even contained in PHP 7.4.0).

@nikic, is this indeed intended behavior?
 [2020-03-17 18:54 UTC]
@cmb: Yes, character devices are not seekable, so ftell should return false.
 [2020-03-18 08:06 UTC]
-Status: Assigned +Status: Verified -Type: Bug +Type: Documentation Problem -Assigned To: nikic +Assigned To:
 [2020-03-18 08:06 UTC]
ftell() for character devices already returned false in earlier
PHP versions; the behavioral change reported by the OP appears to
be related to pipes.  Anyhow, not seekable => ftell() returns
false, makes perfect sense to me.
 [2020-03-20 16:00 UTC] mail at ahmd dot io
Got it now, thanks for clarifying 

I tried to amend ftell docs in the manual using
but it's my first time to touch php docs, hopefully, I did it correctly and did not miss anything :)
PHP Copyright © 2001-2023 The PHP Group
All rights reserved.
Last updated: Sun Dec 03 20:01:28 2023 UTC