php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #18262 Impossible to use INCLUDE inside CLASS definition
Submitted: 2002-07-10 10:26 UTC Modified: 2002-07-10 10:30 UTC
From: bmironov at jonview dot com Assigned:
Status: Not a bug Package: *General Issues
PHP Version: 4.1.2 OS: Linux RedHat 6.1
Private report: No CVE-ID: None
 [2002-07-10 10:26 UTC] bmironov at jonview dot 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

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-07-10 10:30 UTC] bmironov at jonview dot com
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
 [2002-07-10 10:30 UTC] derick@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php


 [2003-06-28 17:16 UTC] velocity at charter dot net
Technically it may not be a bug... however this functionality greatly decreases the ability for developers to oganize class methods neatly and efficiently. How does one go about reporting a "functionality bug?"
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Sun Dec 07 20:00:01 2025 UTC