php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #551 Odd if-else parsing error
Submitted: 1998-07-14 08:29 UTC Modified: 1998-07-14 18:20 UTC
From: mlemos at acm dot org Assigned: zeev (profile)
Status: Closed Package: Parser error
PHP Version: 3.0 Final Release OS: Amiga OS 3.1
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
39 - 14 = ?
Subscribe to this entry?

 
 [1998-07-14 08:29 UTC] mlemos at acm dot org
How come this gives a parsing error,

$locale="en";
 
if($locale!="")
{
 if(file_exists("locale-$locale.php"))
  include("locale-$locale.php");
 else
  $bugs_debug("The include file for locale \"$locale\" does not exist!\n");
}

and this doesn't?

$locale="en";
 
if($locale!="")
{
 if(file_exists("locale-$locale.php"))
 {
  include("locale-$locale.php");
 }
 else
  $bugs_debug("The include file for locale \"$locale\" does not exist!\n");
}

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [1998-07-14 18:20 UTC] zeev
This is a known behavior.  The reason is that right now
include and require are *identical* to actually replacing
them with the contents of the file they're including.
So, if that file includes more than one statement, the
script becomes

if (...)
   stmt1
   stmt2
   ...
else
   ...

which is not valid.

Use curly brackets around include, require and eval statements.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu May 02 02:01:28 2024 UTC