Doc #79389 [Com]: ftell retruns false on linux for STDIN
Edit report at https://bugs.php.net/bug.php?id=79389&edit=1
ID: 79389
Comment by: mail at ahmd dot io
Reported by: mail at ahmd dot io
Summary: ftell retruns false on linux for STDIN
Status: Verified
Type: Documentation Problem
Package: Streams related
Operating System: linux
PHP Version: 7.4.3
Block user comment: N
Private report: N
New Comment:
Got it now, thanks for clarifying
I tried to amend ftell docs in the manual using edit.php.net
but it's my first time to touch php docs, hopefully, I did it correctly and did not miss
anything :)
Previous Comments:
------------------------------------------------------------------------
[2020-03-18 08:06:54] cmb@php.net
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-17 18:54:34] nikic@php.net
@cmb: Yes, character devices are not seekable, so ftell should return false.
------------------------------------------------------------------------
[2020-03-17 18:28:29] cmb@php.net
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 14:00:28] mail at ahmd dot io
Description:
------------
Hi
ftell php function returns false for STDIN on Linux with all php 7.4 versions
https://3v4l.org/LTbpu
The related commit seems to be this one
https://github.com/php/php-src/commit/c1a6f2b9ccd2f022b8b0a056030a287748e98eaa#diff-093fc4d3c1dfbb6819809690e36128d7L246
Test script:
---------------
<?php
var_dump(ftell(STDIN));
Expected result:
----------------
int(0)
Actual result:
--------------
bool(false)
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=79389&edit=1
Thread (2 messages)