简体   繁体   English

jQuery的移动多页与PHP

[英]JQuery mobile multiple pages with php

I am developing my first jquery mobile web app, and am trying to understand the relationship of server-side (PHP) code relating to multiple pages in one HTML file. 我正在开发我的第一个jquery移动Web应用程序,并试图了解与一个HTML文件中的多个页面相关的服务器端(PHP)代码的关系。

In this case I have a single html file which contains all of my various pages for the web app: index, login, register, settings, etc (just the front end, all of the actual data requests are handled via PRG). 在这种情况下,我只有一个html文件,其中包含该Web应用程序的所有各个页面:索引,登录,注册,设置等(仅在前端,所有实际数据请求都通过PRG处理)。 Based on whichever #page is displayed, can I nest my PHP code within the #page div to be run only when that #page div is called, or does ALL of the php run regardless of which page div is called? 基于显示的任何#page,我能否将我的PHP代码嵌套在#page div中以仅在调用该#page div时运行,还是所有的php都运行,而与调用哪个page div无关?

example: 例:

<div data-role="page" id="index"  data-theme="b">
<?php $this is some thing that is pertinent only to elements within the #index page.?>
</div> <!--#index -->


<div data-role="page" id="login"  data-theme="b">
<?php $this is something that is only pertinent to the login page, and will NOT play nice with the other php code in the page.?>
</div> <!-- #login -->

Would BOTH of those php items run, or would only the item in the active #page div run? 这些php项都可以运行,还是仅活动#page div中的项可以运行?

Any help or advice is greatly appreciated. 任何帮助或建议,我们将不胜感激。

Adding on what @Marc B said, when a PHP file is run, it goes through from top to bottom, outputting plain text (text outside tags) and executing the PHP script (running the PHP functions and outputting the printed results). 加上@Marc B所说的,当运行PHP文件时,它从上到下遍历,输出纯文本(标记外部的文本)并执行PHP脚本(运行PHP函数并输出打印结果)。

So in your example, both PHP code blocks would be executed if there were no errors produced. 因此,在您的示例中,如果未产生错误,则将同时执行两个PHP代码块。 As it is now, the first block would produce an error and stop processing. 现在,第一个块将产生错误并停止处理。

A good way to get your head around the concept of server-side vs client-side coding would be to go through the w3schools PHP tutorials: http://www.w3schools.com/php/ 了解服务器端与客户端编码概念的一个好方法是浏览w3schools PHP教程: http : //www.w3schools.com/php/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM