php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #7710 include'ing doesn't work properly
Submitted: 2000-11-09 01:42 UTC Modified: 2001-03-17 00:24 UTC
From: brozen at torah dot org Assigned:
Status: Closed Package: Documentation problem
PHP Version: 4.0.3pl1 OS: Linux
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: brozen at torah dot org
New email:
PHP Version: OS:

 

 [2000-11-09 01:42 UTC] brozen at torah dot org
Please take a look at this: (php3)

http://zeraim.torah.org/~cblack/testdir/index.php3

http://zeraim.torah.org/~cblack/testdir/index.php3?sid=3

Now, try these: (php4)

http://terumah.teamgenesis.com/~cblack/index.php3

http://terumah.teamgenesis.com/~cblack/index.php3?sid=2

Precisely the same code. PHP on zeraim incorporates the header & footer and then parses all as one, while on terumah it is attempting to parse the header & footer as if they were independent of the file into which they are included.

Or in other words, PHP3 used to incorporate a 'require()ed' file without doing any work on it, and then parsed the whole thing together. So you could have an IF statement in the header [ if (...) { ] that ended in the footer [ } ].

No longer! That's why the same code is generating parse errors.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2000-11-09 01:45 UTC] brozen at torah dot org
This bug is also reported at:

http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=75695
 [2000-11-09 09:52 UTC] sniper@php.net
Please read this manual page carefully:

http://www.php.net/manual/function.require.php

---

Changed to Documentation problem as I couldn't 
find the incompatibilities list (for PHP 3 vs. PHP 4)
from the manual.

--Jani

 [2000-11-20 05:28 UTC] brozen at torah dot org
This is not a documentation issue. Read this again before you respond so quickly.
 [2000-11-20 05:31 UTC] brozen at torah dot org
index.php3:

<? require "header.php3"; ?>

sid is set

<? require "footer.php3"; ?>

header.php3:

<?
        if (isset($sid))
        {

?>

footer.php3:

<?
        }
        else
        {
                echo "sid not set";
        }
?>
 [2000-11-25 09:38 UTC] zeev@php.net
This is in fact a documentation issue.
PHP 4.0 changed the behavior of require(), and each separate file must now be parsable by itself.  It's a result of a fundemental change that took place between PHP 3 and 4, and this behavior will remain as is...

You'd have to find an alternative way of doing what you want (which should be fairly easy).

Doc team:  The documentation for require() is no longer close to being accurate for PHP 4.0 in general, and PHP 4.0.2&later in particular...  It's basically just like include() today, except it can't fail, and would bail out if it does.
 [2000-11-26 04:01 UTC] brozen at torah dot org
May I ask why this change was made?

I was wondering if you could help us find an alternate way -- we couldn't find one -- so please share the knowledge with those who couldn't find it easily like you! ;-)

Nonetheless, I can't imagine why functionality like what we're interested in isn't available in PHP. It seems like pretty basic stuff...

Thanks.
 [2001-03-17 00:24 UTC] jmcastagnetto@php.net
change in behavior already documented in manual.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Tue May 06 21:01:31 2025 UTC