Req #11836 [Sus->Csd]: Require nor Include works inner a class file

From: Date: Mon, 07 Sep 2015 17:56:57 +0000
Subject: Req #11836 [Sus->Csd]: Require nor Include works inner a class file
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-195859@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=11836&edit=1

 ID:                 11836
 Updated by:         cmb@php.net
 Reported by:        developer at libero dot it
 Summary:            Require nor Include works inner a class file
-Status:             Suspended
+Status:             Closed
 Type:               Feature/Change Request
-Package:            Feature/Change Request
+Package:            *General Issues
 Operating System:   ms nt 4
 PHP Version:        4.0.4pl1
-Assigned To:        
+Assigned To:        cmb
 Block user comment: N
 Private report:     N

 New Comment:

Closing, because traits address this very issue and are available
as of PHP 5.4.0.


Previous Comments:
------------------------------------------------------------------------
[2001-07-02 11:01:31] cynic@php.net

yes, actual knowledge of the coding technics one uses never did any harm.

I'll leave this suspended as it's a featrue request (and not very likely to get satisfied)

------------------------------------------------------------------------
[2001-07-02 10:53:29] developer at libero dot it

It's a good idea. 
Thank you.
I still hope that require and include will works innner class declaration in future.

------------------------------------------------------------------------
[2001-07-02 10:24:46] cardinal@php.net

Why don't you move your common variables and methods to a separate class, and have your 200
classes extend it?

------------------------------------------------------------------------
[2001-07-02 09:41:47] derick@php.net

Not a bug, this was never supposed to work. making this a feature request.

Derick

------------------------------------------------------------------------
[2001-07-02 09:39:39] 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
`'}'' 
========


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



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


Thread (1 message)

  • cmb@php.net
  • Unknown Message
    • cmb@php.net
« previous php.bugs (#195859) next »