This is a short, thoughtful article written by the guys at WPBeginner that explains how to paste code snippets into WordPress that we find around the web. They fix a lot of sites and review the most common errors (the author estimates 95%) that can blow up your site. PHP isn’t as forgiving like CSS and HTML can be. Most of the time it’s the actual physical placement of the PHP snippet into the file that causes the error, or the opening and closing PHP tags aren’t used at all, or an opening PHP tag wasn’t closed with a ?>.
If you’re beginning PHP, this article may very well save you a LOT of time and frustration.