All it takes is one vote. Make it yours. Login and vote now.
By roshanbh
via roshanbh.com.np
Submitted: May 30 2008 / 08:17
If you don't know how can we execute the PHP code which is entered through textbox or textarea then here is tips for you...
Comments
Stefan Koopmanschap replied ago:
I wouldn't know a single situation where this would be useful. And calling eval() a useful function is stupid. There is a reason it sounds like evil ...
Topnotch replied ago:
This will lead to numerous security vulnerabilities if widely used.
lifewithryan replied ago:
I agree, extremely dangerous, but I "could" see a possible need for something similar. Say perhaps you had a content mgmt system that used something like TinyMCE and your up and coming web master wanted to do some dynamic stuff for a given entry, however, you don't want him mucking with the actual code anywhere. However, I certainly wouldn't use eval, not that my solution would be anymore elegant, but in this case, I'd implement a bbcode type parser where you'd wrap the PHP code in some tags that you would then parse into actual php when the page is rendered. Still VERY VERY dangerous and not recommended, especially with eval...
roshanbh replied ago:
well I've seen few of the places where you've to executed the PHP code inside the textbox, I certainly agree that you can't use it widely not in the user end thats for sure, it's very dangerous.
But sometime you may need to use it at admininstrator sections. I can tell you some examples where you need to do this
1) Few wordpress plugin require to place PHP code, how can you place it in the sider bar of wordpress ?? you must execute the PHP code in that case, we are allowing just administrator to do this, not to each and every user to execute the PHP code
2) In drupal's admin you can see that there is option to place the PHP code inside the textarea for execution...
these are the few examples where the eval is useful and comes handy, and I don't think these reason are stupid...
Voters For This Link (1)
Voters Against This Link (3)