php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #5157 Include function not acting as described in documentation
Submitted: 2000-06-20 21:08 UTC Modified: 2000-07-03 05:28 UTC
From: jordan at eblox dot com Assigned:
Status: Closed Package: Documentation problem
PHP Version: 4.0 Latest CVS (20/06/2000) OS: Linux 2.2.14
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: jordan at eblox dot com
New email:
PHP Version: OS:

 

 [2000-06-20 21:08 UTC] jordan at eblox dot com
the fix for bug #5152 was to change the Include() statement on page.php to Require() (also said to use start_session(), but that had no effect, and is implicitly called by session_register() if no session exists yet according to the php docs).  Code listed below:

------------classdec.php-------------
<?
// class declaration

class TestClass {
	var $a; 

	function heh($str) {
		echo $str . "<br>";
	}
}

?>

-----------index.php-----------------
<?
session_register("sessionvar");
Include("classdec.php");

// creating an instance of a class to pass as a session var to page.php
$sessionvar = new TestClass;
$sessionvar->a = "someval";

echo "<a href=page.php>link</a>";

?>
----------page.php-------------------<?
session_register("sessionvar");
// fix was to change this from Include()
Require("classdec.php");

$anothervar = new TestClass;

// I can use the variables of this instance that was created on index.php and put in a session
echo $sessionvar->a . "<br>";
// I can call this function on another instance of the same class that I created on this page
$anothervar->heh("this is output from the same function that generates an error on the next line");
// .....crash telling me it's an undefined function.
$sessionvar->heh("rhewswh");
?>

===========================================
acording to the documentation in this particular example, the include function and require function should not affect results in the manner that is shown above.  Include() if only differnt from Require if you place it in a for loop or similar structure that will cause it be parsed multiple times.  In this sistuation, there is no such loop, etc.

This may alternativly be listed as a documentation problem.  If there is a good reason for the current behavior of the Include() function, it is not described in the docs.

any comments would be appreciated.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2000-07-03 05:28 UTC] sterling at cvs dot php dot net
You need to have the include before the session_register call.  The difference between include & require is documented.
 
PHP Copyright © 2001-2026 The PHP Group
All rights reserved.
Last updated: Mon Jun 15 22:00:02 2026 UTC