Why I'm having fatal error when adding PHP code to my text format?
I just tracked this down.

What happens is that previewing a node will invoke both the teaser display and full node display, and both of those invoke the PHP code.

My solution was to set the teaser to hidden for the content type (at Structure > Content Types > [your node type] > Manage Fields > Teaser). However, I didn't want to do this for default types like Basic Page, so I created a new type "PHP Tests" and only made the change there.

So I think this shows how PHP in nodes can get ugly, but for people like me who basically want to eval code in the Drupal environment without making a module sometimes, the above is an okay solution.