php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #4402 if() does not work across included files
Submitted: 2000-05-11 12:50 UTC Modified: 2000-05-31 09:42 UTC
From: ct at arborinternet dot com Assigned:
Status: Closed Package: Scripting Engine problem
PHP Version: 4.0 Release Candidate 2 OS: FreeBSD
Private report: No CVE-ID: None
 [2000-05-11 12:50 UTC] ct at arborinternet dot com
The following worked in PHP3, but does not work in PHP4. There are three files, the first 'test.php' includes the other two 'test1.php' and 'test2.php'.

test.php:
  <?php
  include('test1.php');
  include('test2.php');
  ?>

test1.php:
  <?php
  $myvar = 1;
  if ($myvar) {
  ?>

test2.php:
  <html><body>mynum = 1</body></html>
  <?php
  } else {
  ?>
  <html><body>mynum = 0</body>
  </html>
  <?php
  }
  ?> 


Error messages with using include():
  Parse error: parse error in test1.php on line 4
  Parse error: parse error in test2.php on line 8

Error messages with using require():
  Parse error: parse error in test1.php on line 4


Configure parameters:
  % ./configure --enable-track-vars --with-apxs=/usr/local/apache/1.3/bin/apxs --with-mysql --enable-trans-sid --enable-versioning


The documentation indicates that include() and require() will treat the included file as if it were part of the main file. I believe having if() work across included files is an important capability.

Christopher Thompson

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2000-05-31 09:42 UTC] stas at cvs dot php dot net
include()'d files should contain complete valid PHP code. 
That's because they are now independently compiled, not just 
concatenated. If you need concatenation, use string operations then eval().
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Jun 28 11:01:30 2024 UTC