I think it's doable, but you've certainly got your work cut out for you if you want to do it in any kind of secure fashion. This is essentially what any web host who offers PHP is doing for anyone willing to throw a bit of money at them.
What your difference would be is that it'd be open to just anyone in general, unless you do plan on restricting access to authenticated users.
You'll want to read up on hardening your system all the way from PHP / apache down to the OS. There are a number of things that a hardened system will prevent, though, which will limit the usefulness of the testing.
If you do pursue this I would highly recommend a human validation / anti-bot mechanism like Captcha / reCaptcha on your code page.
If you're not well versed on system security then I wouldn't touch it, personally.