Bug #11835 Updated: Include and Require does not work inner a class definition.
| From: | developer at libero dot it | Date: | Mon, 02 Jul 2001 13:27:13 +0000 |
| Subject: | Bug #11835 Updated: Include and Require does not work inner a class definition. | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-58692@lists.php.net to get a copy of this message | ||
ID: 11835
User Update by: developer@libero.it
Status: Closed
Bug Type: Scripting Engine problem
Operating system: win nt 4
PHP Version: 4.0.4pl1
Description: Include and Require does not work inner a class definition.
Well
"include is not allowed there" is not sufficient.
I have 200+ classes that have a common declaration of variables and methods.
Everytime I need to modify this declarations I have to modify this 200+ files.
If I could use require or include there I had only one file to modify.
----- Original Message -----
> ID: 11835
> Old-Status: Open
> Status: Closed
> Bug Type: Scripting Engine problem
>
> include is not allowed there, use the constructor instead
> class {
> function class () {
> include('2.php'); //same with require
> }
> }
>
>
>
> Previous Comments:
> ---------------------------------------------------------------------------
>
> [2001-07-02 09:14:57] developer@libero.it
>
> Require nor Include works inner a class file.
>
> This is the file where I define the class:
> ===== 1.php =====
> <?
> class test {
> include("2.php"); //the same with require
> }
> ?>
> ===== end =====
>
> And this is the file where I have content.
> ===== 2.php =====
> <?
> var $a=1;
> function method1 () {
> $this->a++;
> }
> ?>
> ===== end =====
>
> This does not work.
> The error is:
> ========
> Parse error: parse error, expecting
T_OLD_FUNCTION' or
> T_FUNCTION' or T_VAR' or
> '}''
> ========
>
> ---------------------------------------------------------------------------
>
Previous Comments:
---------------------------------------------------------------------------
[2001-07-02 09:19:33] jan@php.net
include is not allowed there, use the constructor instead
class {
function class () {
include('2.php'); //same with require
}
}
---------------------------------------------------------------------------
[2001-07-02 09:14:57] developer@libero.it
Require nor Include works inner a class file.
This is the file where I define the class:
===== 1.php =====
<?
class test {
include("2.php"); //the same with require
}
?>
===== end =====
And this is the file where I have content.
===== 2.php =====
<?
var $a=1;
function method1 () {
$this->a++;
}
?>
===== end =====
This does not work.
The error is:
========
Parse error: parse error, expecting T_OLD_FUNCTION' or T_FUNCTION' or
T_VAR' or '}''
========
---------------------------------------------------------------------------
Full Bug description available at: http://bugs.php.net/?id=11835