-1
<?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);
        }
    }
4

2 回答 2

3

替换render("home_form.php", ["title" => "Log In"]);render("home_form.php", array("title" => "Log In"));

$values = []

$values = array()
于 2013-09-27T16:50:00.067 回答
0

您使用哪个 PHP 版本?

自 PHP 5.4.0 起提供短数组语法:http: //php.net/manual/en/migration54.new-features.php

于 2013-09-27T16:59:07.410 回答