Bug #10430: require() does not work inside class bodies (ie. to pull in methods)
| From: | cpoirier at shelluser dot net | Date: | Sat, 21 Apr 2001 09:15:35 +0000 |
| Subject: | Bug #10430: require() does not work inside class bodies (ie. to pull in methods) | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-52099@lists.php.net to get a copy of this message | ||
From: cpoirier@shelluser.net
Operating system: Window 98
PHP version: 4.0.4pl1
PHP Bug Type: *General Issues
Bug description: require() does not work inside class bodies (ie. to pull in methods)
In file class.php:
--------------------------------------------------------
<?php
class myclass
{
require( $DOCUMENT_ROOT . "/methods.inc.php" );
}
$myinstance = new myclass;
$myinstance->method();
?>
--------------------------------------------------------
In file methods.inc.php:
--------------------------------------------------------
<?php
function method()
{
print "hi";
}
?>
--------------------------------------------------------
Accessing class.php returns the following error:
Parse error: parse error, expecting
T_OLD_FUNCTION' or T_FUNCTION' or
T_VAR' or '}'' in class.php on line 5
Surely this should work?
--
Edit Bug report at: http://bugs.php.net/?id=10430&edit=1