 <p>If you check PHP Documentation for <code>eval()</code>, this is the description:</p> <blockquote> <p>eval — Evaluate a string as PHP code</p> </blockquote> <p>However, PHP Documentation, itself says that <code>eval</code> is a <em>dangerous</em> construct: Caution</p> <blockquote> <p>The eval() language construct is very dangerous because it allows execution of arbitrary PHP code. Its use thus is discouraged. If you have carefully verified that there is no other option than to use this construct, pay special attention not to pass any user provided data into it without properly validating it beforehand.</p> </blockquote> <p>So, be careful when using <code>eval</code>, very careful. Now back to your question.</p> <p>I think what you need here is a tool that can help you with Syntax checking to detect violations of a defined coding standard. I use ESLint to check violations in Javascript code. For PHP I use both PHPStorm and Sublime Text, and I use PHP Lint and PHPCS. Instead doing eval, I suggest you use one of these OR combination of these tools to achieve you objective.</p> <p>If you are using Jetbrains PHPStorm, you can find these plugins here:</p> <ul> <li><a href="https://www.jetbrains.com/help/phpstorm/2016.2/using-php-code-sniffer-tool.html" rel="nofollow">https://www.jetbrains.com/help/phpstorm/2016.2/using-php-code-sniffer-tool.html</a></li> <li><a href="https://plugins.jetbrains.com/plugin/7887?pr=phpStorm" rel="nofollow">https://plugins.jetbrains.com/plugin/7887?pr=phpStorm</a> I personally prefer to use PHPStorm, it is really among the best PHP IDE out there.</li> </ul> <p>If you prefer to use Sublime, here are the plugins for you: </p> <ul> <li><a href="https://github.com/SublimeLinter/SublimeLinter-php" rel="nofollow">https://github.com/SublimeLinter/SublimeLinter-php</a></li> <li><a href="https://github.com/SublimeLinter/SublimeLinter-phplint" rel="nofollow">https://github.com/SublimeLinter/SublimeLinter-phplint</a></li> <li><a href="https://github.com/benmatselby/sublime-phpcs" rel="nofollow">https://github.com/benmatselby/sublime-phpcs</a></li> </ul> <p>My point is, a good combination of these tools should be enough to ensure sanity of your code.</p> <p>-Thanks</p>