我非常了解使用数据库和服务器,并且刚刚下载了 MAMP。我有一个用 html 和 css 制作的网站,并想向其中注入一个 php 脚本。我已将文件保存在 .php 中,当我从浏览器上的 localhost 端口导航到它时,没有显示任何 html。它只显示一个空白的白页。可能有一个非常明显的答案,但我已经在谷歌搜索了一个小时并没有找到解决方案。
这是 php 脚本。它被包裹在一个
标记文档中的所有其他内容都是 html。
<?PHP
                        $filelocation = "Text.txt";
                        if (!file_exists($filelocation)) {
                        echo "Couldn't find datafile, please contact the administrator.";
                        }
                        else {
                        $newfile = fopen($filelocation,"r");
                        $content = fread($newfile, filesize($filelocation));
                        fclose($newfile);
                        }
                        $content = stripslashes($content):
                        $content = htmlentities($content):
                        $content = nl2br($content);
                        echo $content;
                        ?>