RE: [PHP] BUG: require_once() or die(); = fatal error

From: Rasmus Lerdorf (rasmus_at_php.net)
Date: 11/30/03


Date: Sat, 29 Nov 2003 22:48:08 -0800 (PST)
To: Daevid Vincent <daevid@daevid.com>

By default the CLI version turns off the html in the error messages. And
no, really, there is no bug here. You are testing the return code of
something that doesn't have one. It doesn't make sense.

-Rasmus

On Fri, 28 Nov 2003, Daevid Vincent wrote:

> Hmm... Well Rasmus, I do see your point, however it still seems to me it
> 'should' at least compile and work as I expect it to.
>
> My way, the logic is that the file *is* 'required' (whereas I view 'include'
> files as optional), and I want to exit the program with a graceful message
> instead of the fatal error (which doesn't really doesn't tell me what the
> problem is -- "Failed opening required '1'" doesn't mean anything to me or
> the user) that is shown. My intent was to put a @require_once() so that I
> could do just that. Especially since I'm running my script on the command
> line, and your stock fatal error message uses HTML tags.
>
> Not a critical bug or a show stopper, but I do still feel it is a bug.
>
> > -----Original Message-----
> > From: Rasmus Lerdorf [mailto:rasmus@php.net]
> > Sent: Wednesday, November 26, 2003 8:55 PM
> > To: Daevid Vincent
> > Cc: php-general@lists.php.net
> > Subject: Re: [PHP] BUG: require_once() or die(); = fatal error
> >
> > This code doesn't make much sense. By definition, if require
> > cannot open
> > a file it throws a fatal error, so you would never hit the "or" case
> > anyway. Hence there is no return code from require and you
> > can't write
> > code like this. If you want to test the return code you need to use
> > 'include' instead.
> >
> > -Rasmus
> >
> > On Wed, 26 Nov 2003, Daevid Vincent wrote:
> >
> > > Using PHP 4.2.2 on Linux RH8:
> > >
> > > In a PHP script run from command line,
> > >
> > > require_once("gibberator_data.php") or die("No Data
> > file found\n");
> > >
> > > Causes:
> > >
> > > [root@locutus gibberator]# ./gibberator.php
> > > <br />
> > > <b>Fatal error</b>: Failed opening required '1'
> > > (include_path='.:/php/includes;/usr/share/phpwebtools') in
> > > <b>/home/gibberator/gibberator.php</b> on line <b>13</b><br />
> > >
> > > However
> > >
> > > require_once("gibberator_data.php");
> > >
> > > Works just fine.
> > >
> > > --
> > > PHP General Mailing List (http://www.php.net/)
> > > To unsubscribe, visit: http://www.php.net/unsub.php
> > >
> >
>



Relevant Pages

  • Re: ASP.NET Internationalization bug?
    ... The Microsoft team has confirmed the bug. ... For every programming team that works like you do, ... I don't see too clearly the purpose of declaring a single language ... appropriate as HTML and XHTML standards. ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: ASP.NET Internationalization bug?
    ... What you have been saying all along is that code-behind is "better". ... For every programming team that works like you do, ... I'll be looking forward to the response which your bug filing prompts from the VS Team. ... I have already found, first-hand, that the better of the major search engines use the cc TLD *and* the HTML ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: ASP.NET Internationalization bug?
    ... The Microsoft team has confirmed the bug. ... For every programming team that works like you do, ... My use of language and culture in ASP.Net is a bit different than most. ... I have already found, first-hand, that the better of the major search engines use the cc TLD *and* the HTML ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: ASP.NET Internationalization bug?
    ... The Microsoft team has confirmed the bug. ... For every programming team that works like you do, ... I don't see too clearly the purpose of declaring a single ... which is not as appropriate as HTML and XHTML ...
    (microsoft.public.dotnet.framework.aspnet)
  • CTAN package upgrade: gellmu, version 0.8.2
    ... small improvements as well as bug fixes. ... provides a way to write in an XML document type of one's choice using ... classical HTML (suitable for terminal ... Tables and Tabular now have functioning p cells. ...
    (comp.text.tex)