php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #50853 require does not throw E_ERROR for all failrues
Submitted: 2010-01-27 02:35 UTC Modified: 2010-01-27 06:46 UTC
From: miqrogroove at gmail dot com Assigned:
Status: Not a bug Package: Documentation problem
PHP Version: 5.3.1 OS: *
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: miqrogroove at gmail dot com
New email:
PHP Version: OS:

 

 [2010-01-27 02:35 UTC] miqrogroove at gmail dot com
Description:
------------
"require() is identical to include() except upon failure it will also 
produce a fatal E_ERROR level error."

http://www.php.net/require

This is not really accurate because E_PARSE can prevent execution of the 
required file.  If someone were to use error_reporting(E_ERROR) based on 
the advice above, nothing would get reported in those situations.  Since 
this is also never mentioned on the include() page, it is a bit 
misleading.


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-01-27 06:46 UTC] degeberg@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

It isn't require() or include() that fails when you try including an syntactically incorrect file.

As the manual says: "Files are included based on the file path given or, if none is given, the include_path specified. The include() construct will emit a warning if it cannot find a file; this is different behavior from require(), which will emit a fatal error."

If you try doing something like fopen(%&/%!, 'r'); you will also get a parse error even though fopen()'s failure error level is E_WARNING. That's not because fopen() is failing but because the PHP file simply isn't valid.

You simply cannot continue past a parse error. It doesn't make sense trying to figure out if you meant something else or if you're really just feeding it junk.
 
PHP Copyright © 2001-2026 The PHP Group
All rights reserved.
Last updated: Sat Oct 10 09:00:01 2026 UTC