Smarty

来源:5-3 Smarty的配置与实例化

dy30319

2015-09-23 23:52


<?php

/** * Example Application * * @package Example-application */

require '../libs/Smarty.class.php';

$smarty = new Smarty;

//$smarty->force_compile = true;

$smarty->debugging = true;$smarty->caching = true;$smarty->cache_lifetime = 120;

$smarty->assign("Name", "Fred Irving Johnathan Bradley Peppergill", true);

$smarty->assign("FirstName", array("John", "Mary", "James", "Henry"));

$smarty->assign("LastName", array("Doe", "Smith", "Johnson", "Case"));

$smarty->assign("Class", array(array("A", "B", "C", "D"), array("E", "F", "G", "H"),                               array("I", "J", "K", "L"), array("M", "N", "O", "P")));

$smarty->assign("contacts", array(array("phone" => "1", "fax" => "2", "cell" => "3"),                                  array("phone" => "555-4444", "fax" => "555-3333", "cell" => "760-1234")));

$smarty->assign("option_values", array("NY", "NE", "KS", "IA", "OK", "TX"));

$smarty->assign("option_output", array("New York", "Nebraska", "Kansas", "Iowa", "Oklahoma", "Texas"));

$smarty->assign("option_selected", "NE");

$smarty->display('index.tpl');

老师你好这是smarty demo中的index.php

两个问题

1、没有使用“五配置两方法”

2、程序结束没有“?>"

为什么它能运行

写回答 关注

2回答

  • 世界和平ad
    2015-09-25 13:44:34
    已采纳

    Smarty默认定界符就是{},单独的PHP程序可以不要?> 计算机会把<?php以后的代码都看做PHP程序来执行。在HTML中写PHP时需要?> 这样才能区分HTML代码和PHP代码

    dy3031...

    非常感谢!

    2015-09-25 14:29:56

    共 1 条回复 >

  • 宝慕林8495266
    2022-06-10 18:39:46

    那个不是单引号,是反引号,就是esc下面的第一个键子,英文模式下输入,防止库名、表名、字段名和mysql保留字冲突才使用的^_^...

    sadhedivvgmggjsgdxibq

MVC架构模式分析与设计

通过学习MVC理论知识,由浅入深带您实现人生第一个MVC框架

82364 学习 · 929 问题

查看课程

相似问题