php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #7131 Undocumented change in behaviour of alternate syntax
Submitted: 2000-10-11 05:37 UTC Modified: 2000-10-11 07:07 UTC
From: diego at otello dot alma dot unibo dot it Assigned:
Status: Closed Package: *General Issues
PHP Version: 4.0.3RC2 OS: Linux (RH7.0)
Private report: No CVE-ID: None
 [2000-10-11 05:37 UTC] diego at otello dot alma dot unibo dot it
This used to work with PHP3 and stopped when I upgraded to PHP4. Seems that require() doesen't support opening a block in the included file an closing it in the block that contains the require() itself. Maybe a short example could explain it better...

In test.inc :
<?php
 if(1):
?>
ABC

In test.php3 :
><?php
 require("test.inc");
 echo "Test OK";
endif;
?>

With php3 it worked ("ABC Test OK"), with php4 it stops with parse error on last line of test.inc (sure it doesen't find the expected endif...)

BYtE,
 Diego.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2000-10-11 07:07 UTC] hholzgra@php.net
the scope of a control structure is limited to single files
in php 4 due to compiling reasons

you may include or require files within if statements
or loops but all of the control structures elements
( if-else-endif , for-endfor ) have to be in a single
compile unit (file or eval() string)

this is documented somehow in 
  http://www.php.net/version4/incompatibilities.php,
topic #2
 
PHP Copyright © 2001-2026 The PHP Group
All rights reserved.
Last updated: Fri Oct 09 04:00:01 2026 UTC