[英]using php inside of iframe html tags
I am trying to create a website that displays another website in an iframe. 我正在尝试创建一个在iframe中显示另一个网站的网站。
This is my code: 这是我的代码:
<html>
<title>HTML with PHP</title>
<style>
body {
margin: 0px;
}
</style>
<body>
<?php
$page = $_GET['query'];
echo $page;
?>
<iframe align="center" width="100%" height="100%" src="<?=$page;?>" frameborder="yes" scrolling="yes" name="myIframe" id="myIframe"> </iframe>
</body>
</html>
When I open the php file off of my website (using a url website.com/file.php?query= https://www.google.com , and look in the inspector, I can see the page that the iframe loaded, but it just shows up as a blank page, not the . I have it up at http://www.test.fire-light.tk/web.php?query=url (replace url with any valid url). I am not sure why it shows the blank page. 当我从网站上打开php文件(使用url website.com/file.php?query= https://www.google.com )并查看检查器时,可以看到iframe加载的页面,但它只是显示为空白页,而不是。我在http://www.test.fire-light.tk/web.php?query=url (将url替换为任何有效url)上显示。不知道为什么它显示空白页。
Using Iframe you can call PHP file in HTML file . 使用Iframe,您可以在HTML文件中调用PHP文件。 And write your PHP code in test.php Iframe code
<iframe src="test.php"></iframe>
然后在test.php Iframe代码
<iframe src="test.php"></iframe>
编写您的PHP代码
I think this: 我认为这:
<iframe align="center" width="100%" height="100%" src="<?=$page;?>"
frameborder="yes" scrolling="yes" name="myIframe" id="myIframe"> </iframe>
should be changed into: 应更改为:
<iframe align="center" width="100%" height="100%" src="<? echo $page; ?>"
frameborder="yes" scrolling="yes" name="myIframe" id="myIframe"> </iframe>
Try this instead: 尝试以下方法:
<html>
<title>HTML with PHP</title>
<style>
body {
margin: 0px;
}
</style>
<body>
<?php
$url = $_SERVER['REQUEST_URI'];
$parts = explode('?=', $url);
$page = $parts[1];
echo '<iframe align="center" width="100%" height="100%" src="$page" frameborder="yes" scrolling="yes" name="myIframe" id="myIframe"> </iframe>';
?>
</body>
</html>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.