简体   繁体   English

浏览器显示PHP代码

[英]Browser displaying PHP code

I am running XAMPP in order to use PHP on my local computer. 我正在运行XAMPP以便在本地计算机上使用PHP。 I put all of my scripts inside of the htdocs folder (the default location). 我将所有脚本放入htdocs文件夹(默认位置)中。 Everything used to work great until recently. 直到最近,一切都运转良好。 For example, if I click on an HTML file in htdocs, the file opens up in a browser(like it should). 例如,如果我单击htdocs中的HTML文件,则该文件将在浏览器中打开(应该如此)。 But, if I click submit on a form with an action set to "some-script.php" It goes to the php page and displays the php code. 但是,如果我单击操作设置为“ some-script.php”的表单上的提交,它将转到php页面并显示php代码。 Now, if I type into my browser "localhost/some-html.html" then it works? 现在,如果我在浏览器中输入“ localhost / some-html.html”,那么它可以工作吗? Why is that? 这是为什么? What could I be doing wrong?? 我可能做错了什么?

当您通过在地址栏中输入“ localhost / some-html.html”来访问它时,您将使用XAMPP的服务器和PHP引擎来访问该页面,而您只需双击文件夹中的文件,便会使用默认设置打开该文件程序(恰好是您的浏览器)

定义一个基本的url变量,例如$ baseurl =“ http:// localhost / foldername /”,并在您的操作中使用此变量,例如action =“ example.php”。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM