Tho*_*Mel -10 php io counter input output
我正在尝试创建一个我的网站访问计数器,我做了这样的事情:
contatore.txt:0
index.html的:
<html><head>
</head>
<body>
<p><?php include ("counter.php"); ?></p>
</body></html>
Run Code Online (Sandbox Code Playgroud)
counter.php:
<?php
$file_handle = fopen("contatore.txt", "r");
$line = ((int)(fgets($file_handle))) + 1;
fclose($file_handle);
$fh = fopen( 'filelist.txt', 'w' );
fwrite($fh, (string)($line));
fclose($fh);
echo ((string)($line));
?>
Run Code Online (Sandbox Code Playgroud)
这是问题:浏览器只是自动隐藏PHP代码使用:(你能帮助我吗??谢谢
您的文件已命名index.html.除非你告诉你的服务器.html文件应该被视为PHP脚本,这意味着PHP代码没有被执行 - 它将作为文字文本出现.由于PHP标签使其看起来像HTML,因此您的浏览器正确隐藏了未知/非法标签.
将其重命名为index.php.