普通网友 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 winform的chart曲线生成时有凸起
  • ¥15 msix packaging tool打包问题
  • ¥15 finalshell节点的搭建代码和那个端口代码教程
  • ¥15 用hfss做微带贴片阵列天线的时候分析设置有问题
  • ¥15 Centos / PETSc / PETGEM
  • ¥15 centos7.9 IPv6端口telnet和端口监控问题
  • ¥20 完全没有学习过GAN,看了CSDN的一篇文章,里面有代码但是完全不知道如何操作
  • ¥15 使用ue5插件narrative时如何切换关卡也保存叙事任务记录
  • ¥20 海浪数据 南海地区海况数据,波浪数据
  • ¥20 软件测试决策法疑问求解答