|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2005-07-23 09:30 UTC] tony2001@php.net
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Tue Dec 02 19:00:01 2025 UTC |
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 [...]