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

Linux二进制分析

Linux二进制分析

[美]瑞安 奥尼尔 / 棣琦 / 人民邮电出版社 / 2017-12-1 / CNY 59.00

二进制分析属于信息安全业界逆向工程中的一种技术,通过利用可执行的机器代码(二进制)来分析应用程序的控制结构和运行方式,有助于信息安全从业人员更好地分析各种漏洞、病毒以及恶意软件,从而找到相应的解决方案。 本书是一本剖析Linux ELF工作机制的图书,共分为9章,其内容涵盖了Linux环境和相关工具、ELF二进制格式、Linux进程追踪、ELF病毒技术、Linux二进制保护、Linux中的E......一起来看看 《Linux二进制分析》 这本书的介绍吧!

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

在线图片转Base64编码工具

URL 编码/解码
URL 编码/解码

URL 编码/解码

RGB HSV 转换
RGB HSV 转换

RGB HSV 互转工具