Jump to content

make php work in html files


neugi

Recommended Posts

[quote author=fert link=topic=98964.msg389509#msg389509 date=1151651557]
use change the file extension to .php and then you can use php and html 
[/quote]

I think he means without changing the extension (for example: so it runs on a website that is not php enabled, such as geocities).

I've heard that you can do this with JavaScript. They always say to use this:

[code]<script language="javascript" src="http://whatever/php_script.php."> </script>[/code]

But that's never worked for me. I've also seen this suggested:

[code]<img src="php_script.php" />[/code]

But I only get a red X when I tried it.

Feel free to try them if you like.

I did find a JavaScript snippit that did return the php output, but only the output from the php file and nothing from the original html webpage (no code... nothing). Not only that, but when I tried to refresh the page (after deleting the JavaScript) it wouldn't change. The php output always showed up even with no code in the html file and the php file renamed!

I'm also interested in a way to display a php output on an html page (aside from using an iframe) on a server such as geocities that doesn't support php.

Joe
Link to comment
Share on other sites

If you want your PHP code to be parsed in a HTML file you need to edit the servers config file. Such as for Apache you need to find a file called httpd.conf. Look for a a line like this:
[b]AddType application/x-httpd-php .php[/b]
Now add a space after [i].php[/i] and add .html to the end. Save the httpd.conf file restart Apache. You should now be able to parse PHP code in your html files.
Link to comment
Share on other sites

i've searched for this file, but haven't found what i'm looking for.

this is in the file:
[quote]# This is here for backwards compatability reasons and to support
#  installing 3rd party modules directly via apxs2, rather than
#  through the /etc/apache2/mods-{available,enabled} mechanism.
#
#LoadModule mod_placeholder /usr/lib/apache2/modules/mod_placeholder.so
[/quote]

i've also searched for files containg a string like the one you told me, but nothing there

best
Link to comment
Share on other sites

I discovered something about this the other day.. I'm not sure if it works but try this:

<!DOCTYPE PHP PUBLIC "-//W3C//DTD php Transitional//EN">

I'm not sure if that is 100% correct, otherwise just use the .php extension as advised.
Link to comment
Share on other sites

what version of Apache are you on?
I believe Apache 2 uses apache2.conf instead of httpd.conf it's generally located in /etc/apache2/apache2.conf
[b]generally[/b], all configuration files are located in the /etc/ folder
Link to comment
Share on other sites

[quote author=neugi link=topic=98964.msg389663#msg389663 date=1151675193]
Hi,

version ist: Apache Version 2.0.54

best
[/quote]

ok thanks.
did it occur to you that you should have perhaps tried looking for apache2.conf? :)
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.