Bug #18262 Updated: Impossible to use INCLUDE inside CLASS definition

From: Date: Wed, 10 Jul 2002 14:30:09 +0000
Subject: Bug #18262 Updated: Impossible to use INCLUDE inside CLASS definition
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-13736@lists.php.net to get a copy of this message
 ID:               18262
 Updated by:       bmironov@jonview.com
 Reported By:      bmironov@jonview.com
 Status:           Open
 Bug Type:         *General Issues
 Operating System: Linux RedHat 6.1
 PHP Version:      4.1.2
 New Comment:

Hello,

We are using PHP in our projects. It would be nice to split some of our
class definitions on several files.

It seems a syntax problem for now (include / include_once / require /
require_once are not allowed inside class definition).

Could you please provide solution for the problem?

Thanks,
Boris


Previous Comments:
------------------------------------------------------------------------

[2002-07-10 10:26:40] bmironov@jonview.com

File 1.php
<?php
class Test {
    var $text;
    function Test ($_text) {
        $this->text = $_text;
    }

    require_once ('2.inc');
}

$a = new Test ("ABC");
$a->output();
?>

File 2.inc
<?php
    function output () {
        print $this->text;
    }
?>

It will produce following error:
Parse error: parse error, unexpected T_REQUIRE_ONCE, expecting
T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in
/usr/local/apache/root/php/test/1.php on line 8


------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=18262&edit=1



Thread (4 messages)

« previous php.bugs (#13736) next »