Главная / Язык программирования PHP / Имеются следующие Smarty шаблоны main.tpl <html> <head><title>Test page</title> </head> <body> {section name=person loop=2} <b>Name:</b>{$name[person]} <b>Last Name:</b> {$lastName[person]} <b

Имеются следующие Smarty шаблоны

main.tpl <html> <head><title>Test page</title> </head> <body> {section name=person loop=2} <b>Name:</b>{$name[person]} <b>Last Name:</b> {$lastName[person]} <br> {/section} </body> </html>

Написать программу, которая по этому шаблону генерирует html-страницу с заголовком «Test page» и содержанием вида:

Name: Иван Last Name: Петров Name: Петр Last Name: Иванов

вопрос

Правильный ответ:

<? define("SMARTY_DIR","c://users/nina/Smarty/libs/"); require(SMARTY_DIR."Smarty.class.php"); $smarty = new Smarty; $smarty->template_dir = "c:/smarty_dirs/book/templates/"; $smarty->compile_dir = "c:/smarty_dirs/book/templates_c/"; $smarty->config_dir = "c:/smarty_dirs/book/configs/"; $smarty->cache_dir = "c:/smarty_dirs/book/cache/"; $smarty->assign(array(name =>"Иван", lastName => "Петров")); $smarty->append(array(name =>"Петр", lastName => "Иванов")); $smarty->display("main.tpl"); ?>
<? define("SMARTY_DIR","c://users/nina/Smarty/libs/"); require(SMARTY_DIR."Smarty.class.php"); $smarty = new Smarty; $smarty->template_dir = "c:/smarty_dirs/book/templates/"; $smarty->compile_dir = "c:/smarty_dirs/book/templates_c/"; $smarty->config_dir = "c:/smarty_dirs/book/configs/"; $smarty->cache_dir = "c:/smarty_dirs/book/cache/"; $smarty->config_load("page.conf", "header"); $smarty->assign(array(name =>”Иван”, lastName => "Петров")); $smarty->assign(array(name =>”Петр”, lastName => "Иванов")); $smarty->display("main.tpl"); ?>
<? define("SMARTY_DIR","c://users/nina/Smarty/libs/"); require(SMARTY_DIR."Smarty.class.php"); $smarty = new Smarty; $smarty->template_dir = "c:/smarty_dirs/book/templates/"; $smarty->compile_dir = "c:/smarty_dirs/book/templates_c/"; $smarty->config_dir = "c:/smarty_dirs/book/configs/"; $smarty->cache_dir = "c:/smarty_dirs/book/cache/"; $person[0] = array("Иван", "Петров"); $person[1] = array("Петр", "Иванов"); for ($i = 0; $i < 2; $i++) { $smarty->append(array(name => $person[$i][0], lastName => $person[$i][1])); } $smarty->display("main.tpl"); ?>
Сложность вопроса
81
Сложность курса: Язык программирования PHP
50
Оценить вопрос
Очень сложно
Сложно
Средне
Легко
Очень легко
Комментарии:
Аноним
Зачёт в студне отлично. Иду кутить отмечать халяву с тестами интуит
19 июн 2018
Аноним
Нереально сложно
18 янв 2016
Оставить комментарий
Другие ответы на вопросы из темы интернет-технологии интуит.