国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

smarty模板變量賦值并輸出

Original 2019-06-01 16:05:39 156
abstract:$name = 'chao'; $smarty->assign('name',$name); $courses = ['html5', 'css3']; $smarty->assign('courses', $courses); $book&n
$name = 'chao';
$smarty->assign('name',$name);

$courses = ['html5', 'css3'];
$smarty->assign('courses', $courses);

$book = ['name'=>'PHP開(kāi)發(fā)','price'=>69, 'publish'=>'2018-04-22'];
$smarty->assign('book', $book);



$books = [
    ['name'=>'PHP開(kāi)發(fā)','price'=>69, 'publish'=>'2018-04-22'],
    ['name'=>'MySQL性能分析', 'price'=>39, 'publish'=>'2017-10-10']
    ];
$smarty->assign('books', $books);


class Test
{
    public $site = 'www.baidu.com';
    public function welcome()
    {
        return '訪問(wèn)的網(wǎng)址是:'.$this->site;
    }
}
$test = new Test;
$smarty->assign('test',$test);
<h3>我是: {$name}</h3>
<hr>

<p>前端課程: {$courses[0]},{$courses[1]}</p>

<p>書(shū)名:《{$book.name}》,價(jià)格:{$book['price']}元,出版時(shí)間:{$book.publish}</p>

<p>書(shū)名:《{$books.1.name}》,價(jià)格:{$books[1]['price']}元,出版時(shí)間:{$books.1.publish}</p>

<p>我是:{$test->site}, {$test->welcome()}</p>


Correcting teacher:天蓬老師Correction time:2019-06-03 09:33:58
Teacher's summary:任何一個(gè)模板引擎最基本的功能之就是輸出模板變量, 當(dāng)然還要支持流程控制

Release Notes

Popular Entries