Jump to content

Archived

This topic is now archived and is closed to further replies.

neugi

make php work in html files

Recommended Posts

Hi,

what do i have to change that php code works in html also?

best

Share this post


Link to post
Share on other sites
use change the file extension to .php and then you can use php and html 

Share this post


Link to post
Share on other sites
[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

Share this post


Link to post
Share on other sites
i want that the extension html is prasing the php code ;)

i've got my own server where i can change everything, also the php ini. i only need to know which of them i've to change.

best

Share this post


Link to post
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.

Share this post


Link to post
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

Share this post


Link to post
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.

Share this post


Link to post
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

Share this post


Link to post
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? :)

Share this post


Link to post
Share on other sites
i'm new to linux ;)

now it works i've also to remove the # in from of it ;)

best

Share this post


Link to post
Share on other sites
Glad you sorted it out :)

I will move this topic to the Apache Server section because people are more likely to search for something like this in that forum.

Share this post


Link to post
Share on other sites

×

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.