HTML将我的PHP代码识别为注释 [英] HTML recognizes my PHP code as comments

查看:139
本文介绍了HTML将我的PHP代码识别为注释的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想创建一个Chrome应用,但我拥有相同的问题作为这个人。当我添加.php扩展名并运行应用程序时,它会下载文件。我应该做更多的事情吗?我已经安装了PHP(如果这意味着下载并提取与我的应用程序在同一文件夹中的文件,我会错的)。我是一名初学者...:($ / b
$ b

编辑



你告诉我要安装Apache或IIS,我之前说过我想创建一个Chrome应用程序。



我需要安装Apache吗?我在哪里运行它(I没有本地主机,Chrome扩展程序和应用程序使用chrome-extension://前缀,这意味着它被托管在浏览器中)。有关更多信息(您现在已经有所帮助了)? / p>

编辑2



事实证明,Google Chrome不允许开发者托托在Chrome应用程序中运行PHP。



感谢您的帮助!

解决方案

这意味着服务器或者缺少PHP插件(CGI或者其他)或者服务器不能识别它必须通过一个扩展名为PHP的文件进行预处理。



如果您在不受控制的主机上(例如使用GoDaddy),请确保它们允许PHP(某些的免费主机不会拥有PHP,因为它们会给它带来不必要的安全风险)。如果它是您自己的服务器,请确保您安装了PHP并已启用。



如果它安装了PHP,但您没有解析它,需要使用 .htaccess 文件或配置文件将 .php 扩展名绑定到PHP处理程序。



对于apache,您的http.conf需要以下内容(假设您已经拥有PHP插件):

  AddType application / x-httpd-php .php 

在您的托管目录中放置 .htaccess 文件。






编辑



你提到你安装了PHP。我假设你使用的是Apache,因为IIS现在有一个Web Extensions安装程序,它可以(通常)为你处理难题。所以,说了这么一句,打开你的 http.conf (通常位于 C:\ Program Files \Apache Software Foundation\Apache2.2 \conf\ [使用2.2作为演示版本])。在该文件的底部,添加以下内容[将文件路径替换为与您自己安装相关的文件路径]:

  LoadModule php5_moduleC:/php/php5apache2_2.dll
AddType应用程序/ x-httpd-php .php
PHPIniDirC:/ php

更好的参考可以通过在[webserver]上搜索安装PHP [版本]找到。以下是我能找到的其中一个结果


I want to create a Chrome app, but I have the same problem as this guy. When I add the .php extension and I run the app, it downloads the file.Should I do something more? I have installed PHP (if that means to download and extract the file in the same folder with my app, I'd be wrong). I'm a beginner... :(

EDIT

Some of you told me to install Apache or IIS. I said earlier that I want to create a Chrome app.

Do I need to install Apache? Where would I run it (I don't have a local host, Chrome extensions and apps use the "chrome-extension://" prefix, which means it is hosted on the browser). What about more information (you've all been helpful by now)?

EDIT 2

It turns out that Google Chrome doesn't allow developers toto run PHP inside Chrome apps.

Thanks for your help!

解决方案

This means the server is either missing the PHP plugin (either CGI or otherwise) or the the server doesn't recognize that it must pass a file with the extension in to PHP for pre-processing.

If you're on a host out of your control (e.g. using GoDaddy) then make sure they allow PHP (some of the free hosts won't have PHP as they deam it an unnecessary security risk). If it's your own server, make sure you installed PHP and it's enabled.

If it DOES has PHP installed, but you're not getting it to parse, you'll need to bind the .php extension to the PHP handler using either an .htaccess file or the config.

For apache, your http.conf needs the following (assuming you already have PHP plugin):

AddType application/x-httpd-php .php

Or for something more broad, place an .htaccess file with the above code in your hosted directory.


EDIT

You mentioned you installed PHP. I'm going to assume you're using Apache, as IIS now has a Web Extensions installer that would (typically) take care of the "hard part" for you. So, having said that, open your http.conf (Usually located in C:\Program Files\Apache Software Foundation\Apache2.2\conf\ [using 2.2 as a demo version]). Within that file, at the bottom, add the following [replacing files paths to those that correlate to your own install]:

LoadModule php5_module "C:/php/php5apache2_2.dll"
AddType application/x-httpd-php .php
PHPIniDir "C:/php"

A better reference can be found by googling "install PHP [version] on [webserver]". Here's just one of the results I was able to locate.

这篇关于HTML将我的PHP代码识别为注释的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆