I'm assuming you are using apache with mod_php and not the php compiled as a CGI. You need you have php compiled as an interpreter, i.e. you should have a file called /usr/local/bin/php that is executable.
Then, you need to add what is called a hashbang - the first line of your file should look like:
#!/usr/local/bin/php
This will tell the shell to pass the contents of the file to that executable to run. In doing this you will receive the expected results.
Hope that helps!
Chris King