【问题标题】:How to display PHP page from another server on an html without iFrame?如何在没有 iFrame 的情况下在 html 上显示来自另一台服务器的 PHP 页面?
【发布时间】:2017-08-14 13:46:54
【问题描述】:

我有以下 iFrame HTML:

<html>
<iframe src="page.php" id="ifrm" height = 100%  width = 100% ></iframe>
</table>
</html>

我用它在 html 页面中显示 PHP。

但是,iframe 让我很难过。有没有其他不使用 iFrame 的解决方案?

我需要的基本上是让 HTML 页面在不更改浏览器 url 的情况下显示 php 页面。

顺便说一句:两个页面位于不同的服务器上。

谢谢!

【问题讨论】:

  • 取决于 PHP 脚本在做什么,这将不起作用。
  • 你的意思是 iFrame 是唯一的解决方案?
  • 不,这不是我想说的。还有一些其他的解决方案。我想说的是,根据你想要包含的页面是做什么的,你不能使用这个页面的功能。所以,你可以显示它,但可能用户输入不会给你带来你想要的结果。
  • 您是否考虑过使用 ajax 调用?然后您可以使用 Javascript 手动加载页面...
  • &lt;/table&gt; 结束标记在那里做什么?

标签: javascript php jquery html iframe


【解决方案1】:

您可以尝试使用file_get_contents 读取文件,然后打印它:

<?php
    $sContent =  file_get_contents('page.php'); //Replace 'page.php' with the full URI to the pages you want to show
    print ($sContent);
?>

这适用于大多数服务器设置,但并非总是如此。

【讨论】:

  • 不起作用...它基本上是一个 html 页面,而不是 PHP。如果可能的话,我需要一个使用 HTML 的解决方案。
【解决方案2】:

你可以使用函数file_get_contents('http://urlforsite.com/page')

$externalWebsite = 'http://externalsite.com/page';
$externalContent = file_get_contents($externalWebsite);
echo $externalContent;

【讨论】:

    猜你喜欢
    • 2015-06-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-12-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多