|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #47037 No error when using fopen with emty string
Submitted: 2009-01-08 14:37 UTC Modified: 2009-01-08 19:23 UTC
Avg. Score:1.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:0 (0.0%)
From: yarontal12 at gmail dot com Assigned: felipe (profile)
Status: Closed Package: Filesystem function related
PHP Version: 5.2CVS-2009-01-08 (snap) OS: Win XP
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: yarontal12 at gmail dot com
New email:
PHP Version: OS:


 [2009-01-08 14:37 UTC] yarontal12 at gmail dot com
$fh = fopen("", "r");
that doesn't produce an error, but doesn't return a valid stream either.
Same problem with passing NULL or ''.

Reproduce code:
$fh = fopen("", "r");

Expected result:
Warning: fopen() [function.fopen]: failed to open stream: No such file or directory in test.php on line 2

Actual result:


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2009-01-08 15:48 UTC] crrodriguez at opensuse dot org
Yeah, I agree with you.

Index: main/streams/streams.c
RCS file: /repository/php-src/main/streams/streams.c,v
retrieving revision
diff -u -p -r1. streams.c
--- main/streams/streams.c      24 Nov 2008 15:37:33 -0000
+++ main/streams/streams.c      8 Jan 2009 15:47:34 -0000
@@ -1763,6 +1763,7 @@ PHPAPI php_stream *_php_stream_open_wrap

        if (!path || !*path) {
+               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Filename cannot be empty");
                return NULL;
 [2009-01-08 19:23 UTC]
This bug has been fixed in CVS.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
Thank you for the report, and for helping us make PHP better.

Fixed in 5_2, 5_3 and HEAD.

PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Fri Nov 22 10:01:24 2019 UTC