用于HTML标记生成的PHP库 [英] PHP library for HTML tag generation

查看:84
本文介绍了用于HTML标记生成的PHP库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是一个PHP新手。对不起,如果这是一个常见问题...

I'm a PHP newb. Sorry if this is an FAQ...

假设我有这个HTML表格:

Let's say I have this HTML table:

<table width="100%" cellpadding="12" cellspacing="0" border="0">
  <tr bgcolor="black">
    <td align="left">
      <img src="logo.gif" />
    </td>
    <td>
      <h1>Hello</h1>
    </td>
    <td align="right">
      <img src="logo.gif" />
    </td>
  </tr>
</table>

而不是转义为HTML(?> ...< ;? PHP的)或使用回声与手动字符串结构,我想使用PHP函数来生成代码。我制作了一个图书馆,以便上述示例可以通过以下方式生成:

Instead of escaping to HTML (?> ... <?php) or using echo with manual string construction, I'd like to use PHP functions to generate the code. I cooked up a library so that the above example can be generated with this:

echo table(
  array('width' => '100%', 'cellpadding' => '12', 'cellspacing' => '0', 'border' => '0'),
    tr(
      array('bgcolor' => 'black'),
      td(
        array('align' => 'left'),
        img(array('src' => 'logo.gif'))),
      td(array(), h1(array(), 'Hello')),
      td(array('align' => 'right'), img(array('src' => 'logo.gif')))));

我的问题是,是否已有一个流行或常用的库来执行此操作?

My question is, is there already a popular or commonly used library that does this?

推荐答案

我没有找到库,所以我继续更新自己的 HTML标签库

I didn't find a library so I've continued to update my own HTML tab library.

这篇关于用于HTML标记生成的PHP库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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