PHP模板引擎 phptpl

码农软件 · 软件分类 · 模板引擎 · 2019-08-23 12:58:25

软件介绍

phptpl是一个轻便的PHP模板引擎。不需要什么学习成本就能轻松掌握,简洁就是美。

一个简单的示例:

PHP模板文件 test_phptpl.html
<!-- template for testing phptpl -->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>$TITLE$</title>
</head>
<body>
<center>$TABLE_HEADER$</center>
<table width="100%" border="1" cellspacing="0" cellpadding="0">
    <!-- BEGIN $DETAIL$ SECTION -->
    <tr>
        <td>
            $USER_ID$
        </td>
        <td>
            $USER_NAME$
        </td>
    </tr>
    <!-- END $DETAIL$ SECTION -->
</table>
<!-- IF $LOGIN$ -->
<p>somebody login</p>
<!-- ELSE $LOGIN$ -->
<p>no user login</p>
<!-- ENDIF $LOGIN$ -->
</body>
</html>



测试phptpl文件 test_phptpl.php
<?php
/**
 * test phptpl
 */

require "phptpl.php" ;

// 字符串替换配置
$str_replace_array['$TITLE$'] = "test_phptpl" ;
$str_replace_array['$TABLE_HEADER$'] = "MY_TABLE_HEADER" ;
// 明细替换配置
function detail_function( $in_str = null , $print_flag = false )
{
    if( $in_str == null )
        return null;
    
    $out_str = "" ;
    for( $i = 1 ; $i <= 3 ; $i++ )
    {
        $str_replace_array = array() ;
        $str_replace_array['$USER_ID$'] = "MY_TITLE_" . (string)$i ;
        $str_replace_array['$USER_NAME$'] = "MY_USER_NAME_" . (string)$i ;
        
        $out_str .= phptpl_str( $in_str , $str_replace_array , null , null , null , false ) ;    
    }
    
    if( $print_flag == true )
        print $out_str ;
    
    return $out_str;
}
$section_replace_array['$DETAIL$'] = "detail_function" ;
// 区域存在配置
$if_exist_array['$LOGIN$'] = true ;
// 执行模板处理并立即输出
phptpl_file( "test_phptpl.html" , $str_replace_array , null , null , $if_exist_array , $section_replace_array , true );
?>



执行test_phptpl.php后输出
<!-- template for testing phptpl -->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>test_phptpl</title>
</head>
<body>
<center>MY_TABLE_HEADER</center>
<table width="100%" border="1" cellspacing="0" cellpadding="0">
    <tr>
        <td>
            MY_TITLE_1
        </td>
        <td>
            MY_USER_NAME_1
        </td>
    </tr>
    <tr>
        <td>
            MY_TITLE_2
        </td>
        <td>
            MY_USER_NAME_2
        </td>
    </tr>
    <tr>
        <td>
            MY_TITLE_3
        </td>
        <td>
            MY_USER_NAME_3
        </td>
    </tr>
</table>
<!-- IF $LOGIN$ -->
<p>somebody login</p>
</body>
</html>




本文地址:https://codercto.com/soft/d/12992.html

概率

概率

[俄]施利亚耶夫 / 周概容 / 高等教育出版社 / 2008-1 / 48.00元

《概率(第2卷)(修订和补充第3版)》是俄国著名数学家A.H.施利亚耶夫的力作。施利亚耶夫是现代概率论奠基人、前苏联科学院院士、著名数学家A.H.柯尔莫戈洛夫的学生,在概率统计界和金融数学界影响极大。《概率(第2卷)(修订和补充第3版)》作为莫斯科大学最为出色的概率教材之一。分为一、二两卷,并配有习题集。第二卷《概率(第2卷)(修订和补充第3版)》是离散时间随机过程(随机序列)的内容。重点讲述(强......一起来看看 《概率》 这本书的介绍吧!

图片转BASE64编码
图片转BASE64编码

在线图片转Base64编码工具

正则表达式在线测试
正则表达式在线测试

正则表达式在线测试

HSV CMYK 转换工具
HSV CMYK 转换工具

HSV CMYK互换工具