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
 [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: Wed Oct 30 22:01:28 2024 UTC