普通网友 2014-06-22 21:23 采纳率: 0%
浏览 67

将文件保存为PHP,并且HTML [关闭]

I have code like this

<!DOCTYPE html>
<html>
<head>
<title>test</title>
<?php
 include ('set/tags.html')
?>
<link href="/style.css" rel="stylesheet" type="text/css">
</head>
<body>
<div class="header" id="header">
<?php
include ('set/header.php');
?>
</div>
<div class="menu">
<center>
<?php 
include 'set/menu.php';
?>
</center>
</div>
<div class="mainbody" id="body">
<center>
<table border="0">
<tr>
<td>
<a href="numbers"><img src="img/number.png"  onmouseout="this.src='img/number.png'" onmouseover="this.src='img/number2.png'"/></a>
<br><center><font face="Trebuchet MS" size="4">Numbers</font></center></br>
</td>
<td>
<a href="algebra"><img src="img/algebra.png" onmouseout="this.src='img/algebra.png'" onmouseover="this.src='img/algebra2.png'"/></a>
<br><center><font face="Trebuchet MS" size="4">Algebra</font></center></br>
</tr>
</table>
<?php

$handle = fopen("counter.txt", "r");
if(!$handle){

 echo "could not open the file" ;

}
else {


    $counter = (int ) fread($handle,20);
    fclose ($handle);
    $counter++;
    echo "<strong> You're ". $counter . "<sup>th</sup> visitor</strong>";
$handle = fopen("counter.txt", "w" );
fwrite($handle,$counter) ;
fclose ($handle) ;
    }
?>

</center>
</div>
<div class="footer">
<?php
include 'set/footer.php';
?>
</div>
<div class="side" id="side">

<center>
<?php 
include 'set/side.php';
?>
</center>
</div>

</body>
</html>

and when i save it as index.php, everything works. but when i save it as index.html, php part doesn't work!!

Does any one know what the problem is??

By the way, I'm using Ipage hosting and when i was using 000webhost, it worked when i saved as html

  • 写回答

1条回答 默认 最新

  • duanfoumi5620 2014-06-22 21:26
    关注

    Only files with extension .php (.php3 and .phtml on some servers too) are executed as php script by default. If you have access to server configuration, you can set up server to execute also .html files as script, but I would not recommend it (for performance reasons). Better go "standard way" and name php script files with .php extension.

    评论

报告相同问题?

悬赏问题

  • ¥15 链接问题 C++LNK2001 无法解析的外部符号
  • ¥50 安装pyaudiokits失败
  • ¥15 计组这些题应该咋做呀
  • ¥60 更换迈创SOL6M4AE卡的时候,驱动要重新装才能使用,怎么解决?
  • ¥15 让node服务器有自动加载文件的功能
  • ¥15 jmeter脚本回放有的是对的有的是错的
  • ¥15 r语言蛋白组学相关问题
  • ¥15 Python时间序列如何拟合疏系数模型
  • ¥15 求学软件的前人们指明方向🥺
  • ¥50 如何增强飞上天的树莓派的热点信号强度,以使得笔记本可以在地面实现远程桌面连接