This question already has an answer here:
PHP code is not being executed, instead code shows on the page
This was happening due to the fact that I was NOT hosting a web server on my PC, nor did I have any platform for PHP processing installed. This was confusing to me because it was working on my live domain, hosted by a provider. In my inexperience, it seemed that it should work on my local machine if it was displayed via the domain, but it will not.
In reality, the domain server is processing the .php file and displaying the results for me on my local machine. This means that trying to view a .php file on my local machine does not produce the same results as trying to display the same .php file on my hosted domain.