Page 1 of 1

Compiling a certain piece of code

Posted: Tue Sep 08, 2009 2:08 am
by terrordrone
Hello

I have a certain piece of php code that i load from the database on some condition...

i then create an anonymous function out of it.. using 'create_function'

this function returns a true or false...

assuming the code is safe....

How do i know/test that the code loaded does not cause a compile/syntax error

Ideally i would like to check the syntax error etc before executing and log/inform the user about the error

Any ideas / pointers / help is much appreciated...

Thank you. :)

PS: Im a noob :D

Re: Compiling a certain piece of code

Posted: Tue Sep 08, 2009 2:52 am
by requinix
When you call create_function it compiles on the spot. If there's a problem then you'll get an error.

...Are you really letting users run arbitrary code on your server?

Re: Compiling a certain piece of code

Posted: Tue Sep 08, 2009 3:28 am
by terrordrone
Thanks will check on that...

Not.. not everyone can enter code into the system.. and the condition is extremely dynamic.. we are aware of the security issues that might crop up.. and it will be replaced asap...