php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #41855 Problem with require()
Submitted: 2007-06-29 18:32 UTC Modified: 2007-07-02 13:34 UTC
From: siegler at boskage dot com Assigned:
Status: Not a bug Package: Scripting Engine problem
PHP Version: 5.2.3 OS: Windows Server 2003 (IIS 6)
Private report: No CVE-ID: None
 [2007-06-29 18:32 UTC] siegler at boskage dot com
Description:
------------
I am having problems using a require statement and getting very odd results.  The link of code is: 

require("util.php");

util.php does exist in the same directory as the executing script (I have even run getcwd() to insure my path is getting interpreted correctly).  

Initially I was getting no error output from this, and for some reason when I change the code to read:

require("util.php") or die("blah");

I will get my error, except require is throwing a notice instead of a fatal error so I need this die statement to actually get an error to show, and die never shows the text I pass to the function.

Reproduce code:
---------------
Any require statement may or may not reproduce this issue (for the most part it seems pretty random).  I can temporarily fix this by switching my require to an include, run the script, switch back to require and rerun the script.  It will work then for a short period of time.


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-07-01 13:40 UTC] sniper@php.net
FYI: require / include are not functions, they are language constructs.
And something like 'require() or foo()' isn't gonna work since require exits if file is not found.
 [2007-07-02 13:34 UTC] siegler at boskage dot com
I realize that require 'should' exit when the file is not found.  Part of the problem is that it is not, only a warning is getting thrown instead of a fatal error.  I also realize "require() or foo()" should also not work, but it's been the only way I can get any error message to print to the screen.  

The other part of the problem is that PHP is not finding the file being required.  The file exists and permissions are set correctly on the file.

I'm more than familiar with how the statement should work, and this code worked find until I upgraded to version 5.2.3 of PHP.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Tue May 06 03:01:29 2025 UTC