Hello, I'm launching a new Drupal site and I want to know if there is a safe way to use php inside of nodes and blocks. I have seen all the warnings about php in nodes (or blocks) and that php can crash your Drupal site. So, I figured I would get this php script working first, just in case something bad happens, I won't lose a lot of work. Sure enough, the php script had an error and the whole entire site crashed. Not a big deal, because I did not spend any time configuring the site yet. However... Are their any safe practices for incorporating php inside of Drupal nodes and blocks? This php script is central to my site's concept, and I prefer not to stick it in an iFrame (but I'm thinking about it).
PHP is a strict in terms of syntax. Since php filter in drupal allows you to put php scripts inside your nodes.. you should take enough precautions that php scripts would be interpreted without errors. Otherwise, there is always option to edit it. Unless you mess with core variables of drupal and hooks.. I don't think, php insides nodes would crash your site. It can no doubt crash the nodes where the erroneous script is embedded though.
Maybe use boost module, then all of the content will be cached as static file on your disk, then the php will be used less. hope it works for you
I recommend not embedding PHP directly: it's insecure, and also there can be namespace conflicts (like if there's 2 functions or global variables with the same name in Drupal and your embedded code). If you are absolutely sure there will be no conflict and the code is secure, feel free to embed it. Iframe embedding seems to be the best solution in general.