example_1.php
来自「视频监控网络部分的协议ddns,的模块的实现代码,请大家大胆指正.」· PHP 代码 · 共 69 行
PHP
69 行
<?php/** * Example of usage for HTML_Template_Sigma, basic variables and blocks * * @package HTML_Template_Sigma * @author Alexey Borzov <avb@php.net> * * $Id: example_1.php,v 1.1 2003/04/20 12:40:32 avb Exp $ */ require_once 'HTML/Template/Sigma.php';$listAry = array( array('foo', 'bar'), 'stuff', array('baz', 'quux'), 'more stuff');// instantiate the template object, templates will be loaded from the// 'templates' directory, no caching will take place$tpl =& new HTML_Template_Sigma('./templates');// No errors are expected to happen here$tpl->setErrorHandling(PEAR_ERROR_DIE);// default behaviour is to remove unknown variables and empty blocks // from the template$tpl->loadTemplateFile('example_1.html');// 1. Variable substitution// you can pass a name and a value to setVariable()$tpl->setVariable('var1', 'Value 1');// you can also pass an associative array$tpl->setVariable(array( 'var2' => 'Value 2', 'var3' => 'Value 3'));// setGlobalVariable works the same$tpl->setGlobalVariable('glob', 'I am global');// 2. Empty/nonempty blocks// 2.1 Non-empty blocks$tpl->setVariable(array( 'var_ne_1' => 'Value for block 1', 'var_ne_2' => 'Value for subblock 2'));// 2.2 Empty blocks$tpl->setVariable('var_e_2', 'Value for parent block');// 3. Local/global difference$tpl->setCurrentBlock('list');foreach ($listAry as $item) { if (is_array($item)) { $tpl->setVariable(array( 'local_1' => $item[0], 'local_2' => $item[1] )); } else { $tpl->setVariable('local_1', $item); } $tpl->parseCurrentBlock();}// output the results$tpl->show();?>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?