|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2008-05-23 10:42 UTC] colder@php.net
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Dec 04 05:00:01 2025 UTC |
Description: ------------ Attempting to create a dynamic class definition using eval() to define segments of the class on the fly, fails as PHP does not allow for eval() to be called during class definition. This may be more of a feature request than a bug, but it would seem to me that PHP should allow eval() to operate as normal inside class definitions. Reproduce code: --------------- class foo { eval('var $bar;'); function test($input) { $bar = $input; } } Expected result: ---------------- Should create a class called foo with one attribute, $bar, and a constructor which takes one parameter. Actual result: -------------- Parse error: syntax error, unexpected T_EVAL, expecting T_FUNCTION in W:\www\Internal\foo.class.php on line 3