From: hanskrentel at yahoo dot de Operating system: win32 PHP version: 4.4.0 PHP Bug Type: Feature/Change Request Bug description: include does not work within class() {}
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 bug report at http://bugs.php.net/?id=33831&edit=1 -- Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=33831&r=trysnapshot4 Try a CVS snapshot (php5.0): http://bugs.php.net/fix.php?id=33831&r=trysnapshot50 Try a CVS snapshot (php5.1): http://bugs.php.net/fix.php?id=33831&r=trysnapshot51 Fixed in CVS: http://bugs.php.net/fix.php?id=33831&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=33831&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=33831&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=33831&r=needscript Try newer version: http://bugs.php.net/fix.php?id=33831&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=33831&r=support Expected behavior: http://bugs.php.net/fix.php?id=33831&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=33831&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=33831&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=33831&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=33831&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=33831&r=dst IIS Stability: http://bugs.php.net/fix.php?id=33831&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=33831&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=33831&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=33831&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=33831&r=mysqlcfg