2017-04-13 22:46
浏览 123

如何在浏览器中显示/运行PHP文件? 好像是一个网页[重复]

This question already has an answer here:

How do I run a PHP file in my browser? I know what the file is for and I know how it looks because I tested it online. But now I downloaded it locally to my computer and I do not know how to run it on my browser. Is there a way maybe to link it to a HTML like you do with JavaScript or CSS to make it work on a web browser also after it is online how will I manage it to work?

If I can not link then maybe I can use iframe to see it in a HTML iframe. Is that possible? Yet the question is not based about iframe, but I do not exclude the iframe possibility too. That is why I ask of it too.

Or even better, if there is a way to both link and use iframe for the PHP?

The entire PHP file I got is a email function that works and looks a loot like a HTML and JavaScript file, but it is written in PHP. If I simply change the name to the file from PHP to HTML I can open it in the browser and it looks like a HTML file with few defects since it is a PHP file after all.

The file I downloaded was from here:

And it is this PHP file I am specifically intrested in:

NOTE: I am not asking of "PHP code is not being executed, instead code shows on the page" as the other page is asking. I am asking of "How do I show / run a PHP file in a browser? As if it was a webpage."


图片转代码服务由CSDN问答提供 功能建议

此问题已经存在 这里有一个答案:

  • PHP代码未被执行,而是代码显示在页面上 25 answers

    我如何 在我的浏览器中运行PHP文件? 我知道该文件是什么,我知道它看起来如何,因为我在线测试它。 但现在我将它本地下载到我的电脑上,我不知道如何在我的浏览器上运行它。 是否有一种方法可以将它链接到HTML,就像使用JavaScript或CSS一样,使其在网络浏览器上工作也可以在网上浏览后如何管理它?

    如果我无法链接,那么我可以使用iframe在HTML iframe中查看它。 那可能吗? 然而问题不是基于iframe,但我也不排除iframe的可能性。 这就是为什么我也要问它。


    我得到的整个PHP文件是一个电子邮件功能,它可以运行并看起来像HTML和JavaScript文件,但它是用PHP编写的。 如果我只是将文件的名称从PHP更改为HTML,我可以在浏览器中打开它,它看起来像一个几乎没有缺陷的HTML文件,因为它毕竟是一个PHP文件。

    我下载的文件来自: scripts / php / registrationMailer.php

    这是我特别感兴趣的PHP文件: < p> 注意:我不是要问“PHP代码没有被执行,而是代码显示在页面上”,正如另一页所要求的那样。 我在问“怎么做 我在浏览器中显示/运行PHP文件?好像它是一个网页。“

  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

2条回答 默认 最新

  • dqsvf28682 2017-04-13 22:50

    You need to download a server, and install it. If you want to go to the trouble, you can get XAMPP, and once it's installed, move the PHP file to the root of your installation (usually c:\xampp\htdocs\ on windows) and then use the url localhost/script.php in your browser.

    打赏 评论
  • duankong8998 2017-04-14 01:39

    You do not need a web server to execute PHP script unless you need to run it using a browser. Install PHP in your operating system and include PHP path in your environment path or variable (depending on what OS) you are using. If you are just using the script for the mailing stuff from your own computer, you don't need a web server like apache, you just need PHP and its cli program installed and you be run php scripts directly. Google the web how on how run PHP command line. Or visit this official documentation link:

    打赏 评论

相关推荐 更多相似问题