php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #11837 Require nor Include works inner a class file
Submitted: 2001-07-02 09:44 UTC Modified: 2001-07-02 09:48 UTC
From: developer at libero dot it Assigned:
Status: Not a bug Package: Feature/Change Request
PHP Version: 4.0.4pl1 OS: ms nt 4
Private report: No CVE-ID: None
 [2001-07-02 09:44 UTC] developer at libero dot it
Require nor Include works inner a class file.

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.

This is the file where I define the class, it's only a LITTLE example:

===== class_test.php =====
<?
class test {
  var $b=0;
  var $c=1;
  function test() { //this is the constructor
    //some code here
  }
  
  include("common_declarations.php"); //same with require
}
?>
========  end  ========


And this is the file where I have the common declarations for 200+ files.

===== common_declarations.php =====
<?
var $common_variable1=1;
function common_method1 () {
  $this->b++;
}
function common_method2 ($p=1) {
  $this->b=$p;
}
//etc....
?>
=====  end  =====

This does not work, the error is:

========
Parse error:  parse error, expecting `T_OLD_FUNCTION' or `T_FUNCTION' or `T_VAR' or
`'}'' 
========

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2001-07-02 09:48 UTC] derick@php.net
Submitted twice
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Mar 28 17:01:29 2024 UTC