<?php
// configuration
require("../includes/config.php");
render("home_form.php", ["title" => "Log In"]);
?>
/**
* Renders template, passing in values.
*/
function render($template, $values = [])
{
// if template exists, render it
if (file_exists("../templates/$template"))
{
// extract variables into local scope
extract($values);
// render header
require("../templates/header.php");
// render template
require("../templates/$template");
// render footer
require("../templates/footer.php");
}
// else err
else
{
trigger_error("Invalid template: $template", E_USER_ERROR);
}
}
答案 0 :(得分:3)
替换render("home_form.php", ["title" => "Log In"]);
同
render("home_form.php", array("title" => "Log In"));
和
$values = []
与
$values = array()
答案 1 :(得分:0)
您使用哪个PHP版本?
自PHP 5.4.0以来,可以使用短数组语法:http://php.net/manual/en/migration54.new-features.php