php in html

Status
Not open for further replies.

galaxyAbstractor

Community Advocate
Community Support
Messages
5,508
Reaction score
35
Points
48
I heard somewhere you can make the server blive that the html file is a php file and this way you can include php in the script. How to do it? I am to tired to change all links to the right extenionon my site.
 

racoweb

New Member
Messages
17
Reaction score
0
Points
0
You can mix php code with html code. But to do so, you have to save the file in a proper extension that the php server recognize so it can parse it as such.

I don't understand your question very well...but isn't there a developers forum to ask for this kind of help?
 

Slothie

New Member
Messages
1,429
Reaction score
0
Points
0
Use Addtype in htaccess and set .html extensions to the PHP parser.
 

galaxyAbstractor

Community Advocate
Community Support
Messages
5,508
Reaction score
35
Points
48
Use Addtype in htaccess and set .html extensions to the PHP parser.

Ty.
Edit:
It didn't really work...

wbar.gif
<\/td>(.+) used/", $page, $match); $bar_used = $match[1]; $bar_free = $match[2]; $percent = $match[3]; echo "

{$percent} used."; ?>

Thats what showing when I put:

PHP:
<?php
$username = "viggeswe";
$password = "*password*";
$url = "www.jagf.pcriot.com";
ob_start();
readfile("http://{$username}:{$password}@{$url}:2082/frontend/x3/stats/bandwidth.html");
$page = ob_get_contents();
ob_end_clean();
preg_match("/<img src=bar.gif height=8 width=(.+)><img src=wbar.gif height=8 width=(.+)><\/td><td>(.+) used/", $page, $match);
$bar_used = $match[1];
$bar_free = $match[2];
$percent = $match[3];
echo "<div style=\"background-color: #006600; border: 1px solid #000000; float: left; width: {$bar_used}px;\">&nbsp;</div><div style=\"border: 1px solid #000000; float: left; width: {$bar_free}px;\">&nbsp;</div> {$percent} used.";
?>

Here is the same code in a .php file: http://jagf.net/bandwidth2.php

I added .html to the php handler
 
Last edited:

animerth

New Member
Messages
86
Reaction score
0
Points
0
login to cPanel
goto the bottom of the page look for

Apache Handlers
then click it and look for

Create An Apache Handler

Handler:application/x-httpd-phpv2 or what ever is your curent .php handler (check by looking under System Apache Handlers)

Extension : .html

There you go BTW this might cause a unotcieable delay in .html page because php will try look for data in it
 
Last edited:

galaxyAbstractor

Community Advocate
Community Support
Messages
5,508
Reaction score
35
Points
48
login to cPanel
goto the bottom of the page look for

Apache Handlers
then click it and look for

Create An Apache Handler

Handler:application/x-httpd-phpv2 or what ever is your curent .php handler (check by looking under System Apache Handlers)

Extension : .html

There you go BTW this might cause a unotcieable delay in .html page because php will try look for data in it

Exactly what I did
 
Status
Not open for further replies.
Top