How can I check if user-provided PHP code is valid? Specifically, I have a couple of PHP scripts that users can edit via the UI for a variety of reasons. If users edit those scripts, how can I verify that what they provide is valid and isn't going to crash when it actually gets run?
I thought about using a try-catch block around the entirety of the code, but another concern I have is that when I'm testing any code the user provides, I don't want to actually run the code, as the code may cause changes to be made in the system.
Any thoughts would be greatly appreciated. Thank you.