2

I'm using Ubuntu server 16 and have installed php and when I have a php file, the code breaks at the > and shows the rest of the code on a webpage.

Is something wrong with the code or my server? Thanks

6

The problem was evidently that the file was not using a .php file extension. While Unix-like systems typically don't care what the file extension is (i.e. programs should be able to tell filetype without the extension in most cases), the web server does rely on the file extension to tell it whether or not it needs to do preprocessing.

The solution, of course, is to use a .php extension for the file rather than some other extension.

As a suggestion for troubleshooting in the future, the linked image from the text editor shows based on its coloring that it, in fact, believes something stops at the > character in the if statement. While it is easy to identify this as the result of a wrong file extension in retrospect, it could have been a clue that the issue did not lie in an error in the web server.

Credit for the solution goes almost exclusively to md5madman on for the answer to this question on Stack Overflow.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.