PHP code example of itxiao6 / view

1. Go to this page and download the library: Download itxiao6/view library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

itxiao6 / view example snippets



$path = ['/view_path'];         // 视图文件目录,这是数组,可以有多个目录
$cachePath = '/cache_path';     // 编译文件缓存目录

$compiler = new \Itxiao6\View\Compilers\ViewCompiler($cachePath);

// 如过有需要,你可以添加自定义关键字
$compiler->directive('datetime', function($timestamp) {
    return preg_replace('/(\(\d+\))/', ' echo date("Y-m-d H:i:s", $1);