ID: 11047
User Update by: [EMAIL PROTECTED]
Status: Closed
Bug Type: Feature/Change Request
Operating system: RH Linux 7.0
PHP Version: 4.0.4pl1
Description: Cannot put require() or include() within a class definition

how odd.. I didn't see your "there is no real preprocessor" note earlier.

Alright. in that case, perhaps the documentation for require should be changed to say 
that require *is* subject to containing control structures.

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

[2001-05-23 15:13:37] [EMAIL PROTECTED]
This seems like an easy enough addition, and it makes building large libraries of 
homologous classes MUCH easier.  Of course, there is a work-around: I can inherit 
numerous intermediate classes to simulate multiple inheritance, but that could 
theoretically become a VERY large overhead, if you have many "base" classes to 
inherit.  Doing so also makes it difficult to read the resulting code.

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

[2001-05-23 14:39:40] [EMAIL PROTECTED]
That's how it is, and how it'll be in foreseeable future.

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

[2001-05-23 13:19:35] [EMAIL PROTECTED]
how odd.. I didn't see your "there is no real preprocessor" note earlier.

Alright. in that case, perhaps the documentation for require should be changed to say 
that require *is* subject to containing control structures.

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

[2001-05-23 09:44:01] [EMAIL PROTECTED]
Well, the truth is that there's no real preprocessor in PHP. The fact that it's 
impossible to use include*() or require*() in class definitions is by design, and is 
very unlikely (read "guaranteed not to") to change during the life of 4.x.

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

[2001-05-23 05:36:18] [EMAIL PROTECTED]
class foo {
  function foo() {
  }

  require "foo_functions.php";
}

~~~~

The above code returns the following parse error:

Parse error: parse error, expecting `T_OLD_FUNCTION' or `T_FUNCTION' or `T_VAR' or 
`'}'' in foo.class.php on line 5


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

The remainder of the comments for this report are too long.  To view the rest of the 
comments, please view the bug report online.

Full Bug description available at: http://bugs.php.net/?id=11047


-- 
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to