Why are my php tags converted to html comments?

前端 未结 12 1733
[愿得一人]
[愿得一人] 2020-12-31 19:44

A friend\'s lamp host seems to be misconfigured. I try to execute php, but it doesn\'t seem to be working.

In Chrome\'s inspect element:



        
12条回答
  •  天涯浪人
    2020-12-31 20:11

    Your Chrome is lying to you.

    Your PHP source file is . Because PHP is not executed, this file is sent to the browser. If the browser should interpret this text, it will stumble upon the ?> marks. They have a meaning - they are "XML processing instructions", and the text after the opening angle defines the target.

    Obviously the browser does not know about a target named "PHP", so this text is ignored.

    And then the element inspector tries to display the DOM and is lying about the original source code, because he is working on the PARSED source - which is great because you usually want to know on which data the browser acts, and this includes how the browser interpreted your source.

    But if you make any error, the browser will try to fix it, and the fix is included in the element inspector.

    Obviously the fix for an unknown XML processing instruction is to disable it by commenting it out.

提交回复
热议问题