将HTML \ PHP页面加载到另一个页面的div中 [英] load HTML\PHP pages into another Page's div

查看:87
本文介绍了将HTML \ PHP页面加载到另一个页面的div中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可以说我有两页 links.html & contents.php ...第一页仅包含html代码,第二页包含一些 HTML + PHP代码 ....



现在我用两个DIV创建一个页面 index.php ,其中我想显示上面两页...

 < html> 
< body>
< div id =linksclass =myCustom1>
<! - 这里是links.html页面 - >
< / div>

< div id =contentsclass =myCustom2>
<! - 这里是contents.php页面 - >
< / div>
< / body>
< html>

如何操作 你可以使用include函数(require(),require_once()函数),像这样:

b

(将links.html更改为links.php)

 < html> 
< body>
< div id =linksclass =myCustom1>
<?php include(links.php); ?>
< / div>

< div id =contentsclass =myCustom2>
<?php include(contents.php); ?>
< / div>
< / body>
< html>

我将它设置为links.html,它是您的文件名,但如果它位于您需要指定的子目录中它也是如此。



例如:

  include(subfolder / links.html ); 


lets say i have two pages links.html & contents.php... first page contains only html code while the second page contains some HTML + PHP code....

now i ant to create a page index.php with two DIVs in which i want to show\load the above two pages...

<html>
<body>
    <div id="links" class="myCustom1">
    <!--here will be the links.html page-->
    </div>

    <div id="contents" class="myCustom2">
    <!--here will be the contents.php page-->
    </div>
</body>
<html>

HOW TO DO IT

解决方案

you can use the include functions (require(), require_once() functions would work as well), like this:

(change links.html to links.php)

<html>
<body>
    <div id="links" class="myCustom1">
    <?php include("links.php"); ?>
    </div>

    <div id="contents" class="myCustom2">
    <?php include("contents.php"); ?>
    </div>
</body>
<html>

I set it to links.html which is your filename but if it's in a subdirectory you need to specify it as well.

eg:

include("subfolder/links.html");

这篇关于将HTML \ PHP页面加载到另一个页面的div中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆