php - get_called_class hack not working with eval-code -
I am using a ge_called_class
hack which is delayed in php version 5.2 (found) Allows stable binding from
I have the following in my code:
# db_record.php $ ac = "Forum Refresh"; $ Object = $ ac :: find ("all");
This will not work in PHP 5.2 for some reason, so I have done this:
# db_record.php $ ac = "Forum refresh"; Eval ("\ $ objects = {$ ac} :: search ('all');");
On the other hand it will not work with the get_called_class
function. I get an error that the file
function can not read the blank space in the code.
If you are using eval, then your solution is wrong.
Why would your non-eval version not work? What's going wrong? What is a complete and complete error message? The user-supply version of
get_called_class
does a back lint and tries to open the caller's file to determine the name of the class. The reason eval fails is because the eval backtrace does not provide the file name.
(Edit: Besides, this get_called_class
hack is too much hack. Is there any reason that can not use 5.3?)
Have tried to experiment? Fixed code find
$> for the class name contained in call_user_func (AA ($ AC, 'search'), 'all')
should 'All'
with the AC parameter. Also see
Comments
Post a Comment