Bug #10430 Updated: require() does not work inside class bodies (ie. to pull in methods)

From: Date: Sun, 29 Apr 2001 17:37:17 +0000
Subject: Bug #10430 Updated: require() does not work inside class bodies (ie. to pull in methods)
Groups: php.dev 
Request: Send a blank email to php-dev+get-52962@lists.php.net to get a copy of this message
ID: 10430 Updated by: andi Reported By: cpoirier@shelluser.net Old-Status: Open Status: Closed Bug Type: *General Issues PHP Version: 4.0.4pl1 Assigned To: Comments: Right. require() and include() both happen at run-time while the class is checked for method's at compile-time. You have to include the method definitions inside the class {} Andi Previous Comments: --------------------------------------------------------------------------- [2001-04-21 05:15:35] cpoirier@shelluser.net 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? --------------------------------------------------------------------------- ATTENTION! Do NOT reply to this email! To reply, use the web interface found at http://bugs.php.net/?id=10430&edit=2

« previous php.dev (#52962) next »