I have a class like this:
class Person {
function __construct($name) {
$this->name = $name;
}
function show() {
echo $this->name;
}
}
On my PHP page, I'd like to have a textbox that lets me either type in a custom-language script or a PHP script (without security vulnerabilities somehow) like :
PHP Example:
$me = new Person("Alexander");
$me->show();
And see output on the page with the result of the show()
function. Obviously I don't want people writing malicious code. How is this done? I don't have any experience with this type of programming.
Examples of problem domain:
Interactive "learn php" website. User can type php in and see result without having to set up their own web server.
"Program an attack script" game. User programs their fleet AI and watches the result of the battle against the computer AI.