Seeing the amount of functions available in PHP, which makes it already somewhat difficult to set up shared hosting securely, there is really no way to safely allow users to do this by just blacklisting some statements.
It may, however, if you really now what you're doing, be possible to work with a whitelist of functions that are allowed to execute. If you really want to do this secure, you may be able to achieve this by running the code in an unprivileged PHP parser, and use the results. It is not secure to run the code with the same privileges as your web site.