包括php到另一个PHP和保持包括? [英] Including php to another php and keeping included?

查看:129
本文介绍了包括php到另一个PHP和保持包括?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找类似于php include方法的解决方案,除了在html的iframe标签上,如果我点击包含的php上的超链接,我不希望浏览器将整个标签导航到新的网址,但只导航包含的页面而不会让父页面改变/消失。

I'm looking for a solution similar to the php include method, except like at html's iframe tag, if I click a hyperlink on the included php, I don't want the browser to navigate the whole tab to the new url, but only navigating the included page without getting the parent page change/disappear.

好的,谢谢快速的答案,好像我没有问正确的问题:)所以这里有一些背景信息:整个页面本身是一个单文件网站使用完全相同的javascript + hiddendivs页面改变方法比你刚写的方法。我的问题是:我正在使用一个平面文件CMS来保持我的新闻页面可以被没有编码知识的人管理。所以我为CMS制作了一个自己的模板,只显示新闻。然后我使用php include方法将CMS的index.php嵌入到我的父index.php中它看起来非常好,除了我的问题是,当我点击早期帖子时,它导航到CMS的index.php并加载之前的新闻那里。我希望它能在不导航任何地方的情况下加载早期新闻,就像在html的iframe方法中一样。 (如果没有其他解决方案,我将使用iframe,但如果我想保持跨浏览器支持,它的配置会非常复杂)

okay, thanks for the quick answers, seems like I didn't ask the right question:) so here is some background info: the whole page itself is a single-file website using the exactly same javascript+hiddendivs page changing method than that you just wrote. my problem is: I'm using a flat-file CMS to keep my News page managable by people having no coding knowledge. so I made an own template for the CMS only showing the news themselves. Then I embedded the CMS's index.php to my parent index.php with php include method and it looks really well, except my problem is, when I click "earlier posts", it navigates to the CMS's index.php and loads earlier news in there. I'd like it to load earlier news without navigating anywhere, just like at html's iframe method. (I will use iframe if there is no other solution, but its configuration would be really complicated if I wanted to stay cross-browser supportive)

推荐答案

为此,您必须了解您正在处理的内容。

To do this you must understand what you are dealing with.

* .php 页面已加载进入用户的浏览器是一个经过处理和解析的页面。
此解析发生在服务器端,由服务器上的PHP处理器处理。
现在,在处理了 * .php 文件后,与它的任何交互都将丢失。用户(客户端)唯一看到的是此处理的结果。因此,要与此页面通信,必须发送信息。

The *.php page loaded into user's browser is a processed and parsed page. This parsing occurs at the server-side, and processed by the PHP processor on the server. Now, after a *.php file is processed any interaction with it is lost. The only thing a user (client-side) sees is the result of this processing. Hence, to communicate with this page an information must be sent.

通常,浏览器会发送有关请求页面的信息。这就是 HTTP 协议的工作原理。

Normally, browsers send information on requesting a page. That is how the HTTP protocol works.

由于用户是客户端,他必须通过协议规则发送相关信息(标题,变量等)。这意味着,用户必须请求页面,并且通过此请求将发送数据。

Since the user is the client-side, he must send relevant information (headers, variables, etc.) by the rules of the protocol. This means, a user must request the page and by this request the data will be sent.

AJAX技术允许您打开 HTTP 在后台动态请求,而页面仍在运行而无需刷新。它根据协议的约定发送相关数据,并允许您触发回调函数,以便在服务器到达时处理答案。

AJAX technology allows you to open an HTTP request dynamically, on the background, while the page is still running with no need to refresh. It sends the relevant data according to protocol's convention and allows you to trigger a callback function to handle the answer when it arrives from the server.

在这里你可以找到一本初学者的教程,它将为你提供必要的信息。

Here you can find a beginner's tutorial, that will provide the necessary information for you to start.

PS

我强烈建议您不要使用常见的外部库,如jQuery,node.js,Backbone.js等在一开始。这些库是为简化高级开发人员的代码编写而创建的工具。他们可能会混淆你并弄乱你的编程逻辑和学习路径。

I would strongly recommend you not to use common external libraries like jQuery, node.js, Backbone.js etc. at the beginning. These libraries are tools that were created to simplify code writing for advanced developers. They may confuse you and mess up your programming logic and learning path.

祝你好运!

这篇关于包括php到另一个PHP和保持包括?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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