ID: 33831 Updated by: [EMAIL PROTECTED] Reported By: hanskrentel at yahoo dot de -Status: Open +Status: Wont fix Bug Type: Feature/Change Request Operating System: win32 PHP Version: 4.4.0 New Comment:
Class methods are evaluated at compile time and cannot be added during runtime. That's well documented (http://php.net/manual/en/language.oop.php) and that's how it works. Previous Comments: ------------------------------------------------------------------------ [2005-07-23 01:52:55] hanskrentel at yahoo dot de Description: ------------ the include() and require() statements do not work within the class() {} block. that's really a pitty, because it would be nice to put some function out of the class main file to make it easier to maintain larger class files. this is not new. but there is a new scenario not in the database: ----------------------- this seems to be a real bug in some cases. even if include works within a function statement within a class statement, it can not close this functions code-block even if it does. so this does not "works as expected" as stated by ernest at vogelsinger dot at. you get no error in that kind of code but the function is not defined at all: class_a.php: <? class A { function B () { include('class_a_c_method_tricky.php'); /* code of function Ctricky */ } } ?> class_a_c_method_tricky.php: <? /* code of function B */ } function C () { /* code of function C */ } function Ctricky() { ?> the include is done (no error), but class A->C() is not defined. something is messed up here. Reproduce code: --------------- class.foo.php: <? class foo() { function foo() { $this->that = 'whatever'; } include('class.foo-functions.php'); } $c = new foo(); $c->fob(); ?> class.foo-functions.php: <? function fob() { echo 'fob'; } ?> Expected result: ---------------- fob Actual result: -------------- Parse error: parse error, unexpected T_REQUIRE, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in [...] ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=33831&edit=1
