将文本输入解释为PHP [英] Interpret text input as PHP
问题描述
我想让用户测试我的PHP类,其中包括裁剪和调整图像大小.
I want to let users test out a PHP class of mine, that among other things crops and resizes images.
我希望他们在文本字段中编写PHP代码,发送表格,然后运行他们的代码.我该怎么办?
I want them to write PHP code in a text field, send the form, and then their code will be run. How can I do this?
还是让用户(任何人)演示PHP类的其他安全方法?
Or is it other safe ways to let users (anyone) demo a PHP class?
推荐答案
是.您可以在php中使用eval语句(之前由John http://us2链接.php.net/manual/en/function.eval.php ),但是请务必小心.您真的不希望用户能够在您的计算机上自由运行代码.
Yes. You can use the eval statement in php (linked earlier by John http://us2.php.net/manual/en/function.eval.php), however be very careful. You really don't want users to be able to run code on your machine freely.
我的建议是尝试提出一种不同的演示方法-也许是一些灵活的示例...但是不要让他们直接运行代码
My recommendation would try to come up with a different approach to do demos - perhaps a flexible few examples... but don't let them run code directly
这篇关于将文本输入解释为PHP的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!