Question: I would like to make something like *tryruby.org*. I take a line from the user (e.g., `echo __FILE__`) and I want to execute it in PHP and return the output back to the client.

I tried to do `exec('php -r ' . $command, $output)`, but `$output` always contains the PHP help section.

How can I implement this feature?

Answer: 
To make `php -r` you have to have to put the code you want to execute between `'` .. your code .. `'`

Example:

```
php -r ' $var = 34; print_r($var); '

```
Look up 'eval()' and more importantly, why eval() and what you're trying to do is very difficult to achieve in a secure manner. Imaging for example the user who inputs:

```
echo file_get_contents('/etc/passwd');

```

You'll need quite a bit of work to make this secure, including watching and filtering all system calls being made from the eval'd process.

Cheers