Bug #17987 Updated: require() not permitted within class definition
| From: | david-work at robinson-au dot net | Date: | Wed, 26 Jun 2002 05:04:24 +0000 |
| Subject: | Bug #17987 Updated: require() not permitted within class definition | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-12103@lists.php.net to get a copy of this message | ||
ID: 17987
Updated by: david-work@robinson-au.net
Reported By: david-work@robinson-au.net
-Status: Bogus
+Status: Open
-Bug Type: Class/Object related
+Bug Type: Feature/Change Request
Operating System: Windows 2000
PHP Version: 4.2.0
New Comment:
The class definition is very long, and I want to break the class
definition into multiple files.
The first suggestion was to place the require() statement outside the
class. This will not split the class definition into multiple files.
The second suggestion was to place the require() statement inside the
function. Unfortunately this will separate the function definition and
the function body into two separate files. This will result in less
readable code.
Therefore I request that include() and require() statements be
permitted inside a class definition, and between function definitions.
This modification is the most appropriate place to split a long class
definition, and will also improve the flexibility of the php
scripting.
Kind regards
David Robinson
Previous Comments:
------------------------------------------------------------------------
[2002-06-26 00:48:01] alan_k@php.net
Sorry, but the bug system is not the appropriate forum for asking
support questions. Your problem does not imply a bug in PHP itself.
For a list of more appropriate places to ask for help using PHP,
please visit http://www.php.net/support.php
Thank you for your interest in PHP.
thats designed behaviour = put the include outside the class or inside
the function/methods.
------------------------------------------------------------------------
[2002-06-26 00:30:27] david-work@robinson-au.net
Hello
The include() and require() statements do not work within a class
definition.
This may be a parsing problem, or it may behave as designed.
See below for an example script and the errors generated.
I am running the precompiled binary downloaded from the php.net
website.
Many thanks
David Robinson
*** Example 1
<?PHP
class test
{
function f1()
{
...
}
include('file.php');
function f2()
{
...
}
}
?>
*** End Example 1
*** Error 1
Parse error: parse error, unexpected T_INCLUDE, expecting
T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' ...
*** End Error 1
*** Error 2
Parse error: parse error, unexpected T_REQUIRE, expecting
T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' ...
*** End Error 2
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=17987&edit=1