Skip to content Skip to sidebar Skip to footer

Html Recognizes My Php Code As Comments

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 in

Solution 1:

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.

Solution 2:

Do you have a server installed on your machine? PHP is a server-side script & unlike Javascript you cannot run it without a server.

Solution 3:

PHP files are server side code only. So you need to install a local server like APACHE to get the PHP script to execute.

Solution 4:

PHP must be run on a web server, not your desktop. Install PHP on your webserver, then open the PHP file from a web browser via: http://localhost/yourfile.php

Solution 5:

You need an Apache server on your computer. download xampp: http://www.apachefriends.org/en/xampp.html and put your files in the htdocs folder.

EDIT: This will explain how to install a PHP environment: http://www.tanguay.info/web2008/tutorial.php?idCode=phpDevelopmentQuick

Post a Comment for "Html Recognizes My Php Code As Comments"