如何在main_page.php的div容器中调用sub_page.php?
我需要在main_page.php中显示sub_page.php的内容 目前,我正在使用iframe来实现这一点,但我想在div中显示sub_page.php,这样它会有一个更专业的外观 我该怎么做如何在main_page.php的div容器中调用sub_page.php?,php,html,Php,Html,我需要在main_page.php中显示sub_page.php的内容 目前,我正在使用iframe来实现这一点,但我想在div中显示sub_page.php,这样它会有一个更专业的外观 我该怎么做 <HTML> <HEAD> <meta http-equiv="content-type" content="text/html; charset=iso-8859-1" /> </HEAD> <BODY> <div st
<HTML>
<HEAD>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
</HEAD>
<BODY>
<div style="text-align:center;"><img src="faq-banner.png" /></div><br />
<div>
<?php include("faq.php"); ?>
</div>
</BODY>
</HTML>
在div中,使用简单的include()
命令包含php页面
<div>
<?php include("subpage.php"); ?>
</div>
我想你要做的就是:
include('sub_page.php');
在试图显示子页面的div
中包含此代码。尝试包含并计算指定文件的语句:
例如:
vars.php
<?php
$color = 'green';
$fruit = 'apple';
?>
test.php
<?php
echo "A $color $fruit"; // A
include 'vars.php';
echo "A $color $fruit"; // A green apple
?>
不工作,它一直试图加载。。我在第一篇文章中添加了我的页面代码。您的代码不足以理解。iframe在哪里?你想在哪里加载子页面?我删除了iframe并用div替换了它,就像你通知的那样。我想在boddy中加载banner.jpg图像之后的sub_页面。@LucasMatos,它应该按照您的方式工作。faq.php
的内容是什么?它现在运行得很好,但我的网站侧栏显示在子页面div下面。你知道如何使侧栏在原来的位置显示吗?