使用file.asp提供的示例,我正在使用html学习php。在尝试通过在浏览器上点击html文件在服务器上使用php打开文件时,我发现没有在服务器上创建任何文件,而php部件似乎没有在那里运行。下面是我使用的确切文件
<html>
<body>
<?php
$file=fopen("welcome.txt","w+");
fwrite($file, "test");
?>
</body>
</html>
Below are apache details,
[root@ learneg]# httpd -v
Server version: Apache/2.2.15 (Unix)
Server built: Feb 7 2012 09:50:11我也尝试过其他的密码,但没有成功。请给我建议一下我在这里可能会错过什么
发布于 2014-03-25 08:30:56
您需要配置Apache,因此它也将解析.html文件。查找AddType在httpd.conf中的部分并添加/取消注释如下:
AddType应用程序/x .htm
AddType应用程序/x .html
发布于 2014-03-25 08:31:34
对此应该有一个简单的解释。
你在apache上运行它。
1) Is php5 installed on apache ?
2) Are you sure the php5 module is enabled ?
3) Does the file have a .php extension ?Apache只在看到.php扩展时才解析php。
您也可以尝试这样做:
$file_contents = fopen( "<yourfile>", "r" );
print $file_contents; // This prints the output if it can find it.
fclose($file_contents);
// Write it to a another file.https://stackoverflow.com/questions/22628968
复制相似问题