Why are my php tags converted to html comments?

前端 未结 12 1682
[愿得一人]
[愿得一人] 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:20

    Sounds like you are using an editor that is changing what you enter. Make sure that what you want in the file is what is actually in the file. Using FTP to upload a php file should ensure this.

    0 讨论(0)
  • 2020-12-31 20:20

    It seems you have to instruct apache explicitly to handle html files as php files, I was having the same problem but renaming the file to .php solved the issue for me.

    0 讨论(0)
  • 2020-12-31 20:22

    I just solved this same problem. You need to open your file from your WAMP, and not from your hard drive directrory.

    In your browser, put: localhost/...../yourfile.php

    Otherwise, your browser will replace all <?php ?> with <!-- ?php ?-->

    0 讨论(0)
  • 2020-12-31 20:25

    I was faced with exact same problem when I accidently tried to test local php file in browser on server through file:// protocol, not through installed site.

    So the answer is one: "Mr. PHP has left the building". We need to check the configuration, location of a file or access.

    And browser is just trying to fix a web page and help us.

    0 讨论(0)
  • 2020-12-31 20:26

    This answer doesn't apply to the OP's specific variant of this problem, but I had the basic same issue – <? var_dump($test); ?> being converted to <!--? var_dump($test); ?--> – which I could solve by enabling short_open_tag in php.ini.

    0 讨论(0)
  • 2020-12-31 20:28

    If you are placing your code outside the standard directories (development scenario, in my case) you should check in your /etc/apache2/mod-enabled or /etc/apache2/mod-available in the php5.conf (for ubuntu) and comment the lines that the comment indicates:

    # To re-enable PHP in user directories comment the following lines
    # (from <IfModule ...> to </IfModule>.) Do NOT set it to On as it
    # prevents .htaccess files from disabling it.
    <IfModule mod_userdir.c>
        <Directory /home/*/public_html>
            php_admin_value engine Off
        </Directory>
    </IfModule>
    
    0 讨论(0)
提交回复
热议问题