PHP Bugs  
php.net | support | documentation | report a bug | advanced search | search howto | statistics | login

go to bug id or search bugs for  

Bug #7710 include'ing doesn't work properly
Submitted:9 Nov 2000 1:42am UTC Modified: 17 Mar 2001 12:24am UTC
From:brozen at torah dot org Assigned to:
Status:Closed Category:Documentation problem
Version:4.0.3pl1 OS:Linux
View/Vote Developer Edit Submission

Welcome! If you don't have a SVN account, you can't do anything here. You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
SVN Username: SVN Password:
Quick Fix:
Status: Assign to:
Category:
Summary:
From: brozen at torah dot org
New email:
Version: OS:
New/Additional Comment:

[9 Nov 2000 1:42am 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.
[9 Nov 2000 1:45am UTC] brozen at torah dot org
This bug is also reported at:

http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=75695
[9 Nov 2000 9:52am 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
[20 Nov 2000 5:28am UTC] brozen at torah dot org
This is not a documentation issue. Read this again before you respond so
quickly.
[20 Nov 2000 5:31am 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";
        }
?>
[25 Nov 2000 9:38am 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.
[26 Nov 2000 4:01am 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.
[17 Mar 2001 12:24am UTC] jmcastagnetto@php.net
change in behavior already documented in manual.

RSS feed | show source 

PHP Copyright © 2001-2009 The PHP Group
All rights reserved.
Last updated: Sat Nov 21 10:30:49 2009 UTC