What does the ‘view source’ in your browser show?
If it shows the raw php code, it means that either you didn’t request the page through a URL on a web server, i.e. directly opened the page through the file system in your browser, or that php is not installed/working on that web server and that whatever browser/client you are using rendered the string in the raw php code as html to be output on the page (I just tested in three different browsers and none of them did this.)
If it doesn’t show the raw php code, then either you requested the page using a post method request, perhaps from a form on some other page, or you have a version of the php code that only has one = (an assignment operator) in the comparison with the "POST"
value.
BTW - don’t do this -
This is junk code either directly or indirectly from w3schools. It is validating the raw post value, which could contain all white-space characters, then uses the result from the test_input() function, which trims the value, throughout the rest of the code (the other things the test_input function does are improper for input data - delete this function from your code and don’t ever use it). This will allow someone to submit white-space character(s) that will then get converted to an empty string. Do you really think that your code should attempt to use an empty string?
Instead, your code should trim all the input data at once, using one single php statement, by keeping the post data as a set, in an array variable, then accessing elements in this trimmed working copy of the post data throughout the rest of the code.
Don’t do this as well -
To get a form to submit to the same page, simply leave out the entire action="…" attribute.