English 中文(简体)
如何使用 MVC 从 PHP 生成模板化 HTML
原标题:How to use MVC to generate templated HTML from PHP

我有相当复杂的 HTML 文件, 需要生成窗体的 HTML 文件

一个带有多种 HTML 模板版位的体体。 简而言之, 我大概有一个 PHP 函数( 让我们假装这个域是新闻文章, 因为最简单) 类似

generateNewsBlob($title, $author, $imageSrc)
showUserInfo($userInfoStruct)
//etc.

以在模板中填充参数的方式输出 HTML。

At minimum I just want a nice folder with easy to edit PHP and easy to edit HTML and CSS. As of now I have it all smooshed together in a .php file - something like lots of HTML <img src=" . $imgSrc . " > more HTML ... which makes it very hard for our designer to make modifications and our coder (that d be me) to make modifications. So I need this to be decoupled. But I m not sure how to have a pure html file that has "holes" to be filled in by the php, because I would implement those holes in PHP... catch-22.

先前的一个SO问题中曾指出,MVC是实现这一目标的途径。这听起来令人难以置信,但我不知道该如何去做。我无法引进任何IDE - 开发者应该能够在主控台的文本编辑器中进行这项工作。

Python 和 Java 也是选项 如果它们碰巧是"更好"的话。

最佳回答

PHP 和其他平台有许多 MVC 框架。 http://www.phpwact.org/php/mvc_frameworks 使用这些框架有许多好处,但如果你想更简单一些,你可以使用 PHP 柔性引擎>http://www.smarty.net/

问题回答

暂无回答




相关问题
CSS working only in Firefox

I am trying to create a search text-field like on the Apple website. The HTML looks like this: <div class="frm-search"> <div> <input class="btn" type="image" src="http://www....

image changed but appears the same in browser

I m writing a php script to crop an image. The script overwrites the old image with the new one, but when I reload the page (which is supposed to pickup the new image) I still see the old one. ...

Firefox background image horizontal centering oddity

I am building some basic HTML code for a CMS. One of the page-related options in the CMS is "background image" and "stretch page width / height to background image width / height." so that with large ...

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!

热门标签