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 Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: mlemos at acm dot org
New email:
PHP Version: OS:

 

 [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

Pull Requests

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: Mon Dec 30 14:01:28 2024 UTC