开发者

Need to Error Trap include_once somehow

Ok, I'm allow开发者_如何学运维ing the uploading of files which can have multiple functions in them. I need to be able to somehow error trap the include_once so that if the function_exists already and that function is being called within the file that is uploaded, than it, either 1 sends an error message, or 2 doesn't include the file at all.

Any Ideas?

I've done this: @include_once($filename); but than I get a blank page instead of an error message.

Or is there a better way to do this with the filename and filepath?


What version of PHP are you using? With namespaces in the recent versions you can get around the function exists conflict.

Otherwise you can use the tokenizer functions (http://us.php.net/manual/en/function.token-get-all.php, http://us.php.net/manual/en/tokens.php) with T_FUNCTION and parse them out, keep a file or db table of existing functions and when you upload a new file check it against the table and add new ones.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜