【发布时间】:2013-03-05 05:44:34
【问题描述】:
我正在开发我的第一个 jquery 移动网络应用程序,并试图了解与一个 HTML 文件中的多个页面相关的服务器端 (PHP) 代码之间的关系。
在这种情况下,我有一个 html 文件,其中包含 Web 应用程序的所有各种页面:索引、登录、注册、设置等(只是前端,所有实际数据请求都通过 PRG 处理) .根据显示的任何 #page,我可以将我的 PHP 代码嵌套在 #page div 中以仅在调用该 #page div 时运行,还是无论调用哪个页面 div 都运行所有 php?
示例:
<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 -->
这两个 php 项目会运行,还是只有活动#page div 中的项目运行?
非常感谢任何帮助或建议。
【问题讨论】:
-
php 没有 html 的概念。这只是文字,真的。 php 不会“看到”您的数据角色,它只会在
<?php ?>块内执行 ANYTHING。如果您只希望其中一个块“运行”,那么在服务器上构建页面时,您将需要适当的if()-type 逻辑。
标签: php jquery web-applications jquery-mobile