stacey icon indicating copy to clipboard operation
stacey copied to clipboard

Get rid of evals

Open herrquark opened this issue 14 years ago • 2 comments

herrquark avatar Dec 08 '10 14:12 herrquark

instead of foreach($assets as $asset_type => $asset_files) eval('$page->'.$asset_type.'=$asset_files;'); why not use something like foreach($assets as $asset_type => $asset_files) $page->$asset_type = $asset_files; etc.

herrquark avatar Dec 08 '10 14:12 herrquark

Irritatingly, that technique doesn't work with all versions of php5. Even worse, the correct technique, call_user_func has bugs on certain php5.* versions, but not all. So eval turns out to be the only way (that I know of) to do this, while supporting all php5 variations.

kolber avatar Dec 17 '10 05:12 kolber