Compiling a certain piece of code

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
terrordrone
Forum Newbie
Posts: 2
Joined: Tue Sep 08, 2009 2:00 am

Compiling a certain piece of code

Post 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
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: Compiling a certain piece of code

Post 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?
terrordrone
Forum Newbie
Posts: 2
Joined: Tue Sep 08, 2009 2:00 am

Re: Compiling a certain piece of code

Post 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...
Post Reply