Drupal provides a PHP input filter out of the box. It lets you use custom PHP inside nodes and blocks. The downside is that this PHP code is stored in the database. Upon a new page request this code must be retrieved from the database and executed through PHP's eval() function.
But the biggest drawback is this: the PHP input filter is not cached. The solution is to write a custom Drupal module to do the task.
- Custom modules are cached, PHP input filter is not