这在技术上会作为 php 中的基本模板系统传递吗?
于是就有了两个文件,index.php 和 Template_Module.php
这是 index.php 代码
<?php
include("Template_Module.php");
$set_name = "My Website";
$set_desc = "My Website for random bla bla";
$set_key = "site, random, bla, for";
echo template_header_object($set_name, $set_desc, $set_key);
这是 Template_Module.php 代码
<?php
function template_header_object($set_title, $set_desc, $set_keywords) {
$title_object = htmlspecialchars($set_title); //lets get html title to pass
$desc_object = htmlspecialchars($set_desc); //lets get meta description to pass
$keyw_object = htmlspecialchars($set_keywords); //lets get meta keywords to pass
$template_create_object .= <<<OBJECT
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>$title_object</title>
<!-- general meta -->
<meta name="description" content="$desc_object">
<meta name="keywords" content="$keyw_object">
<!-- mobile specific meta -->
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<!-- open graph meta -->
<meta property="og:title" content="$title_object">
<meta property="og:image" content="/assets/img/logo_fbtype.png">
<meta property="og:site_name" content="$title_object">
<meta property="og:description" content="$desc_object">
<!-- style sheets and scripts -->
<link href="/assets/css/style.css" rel="stylesheet">
<link href="/assets/css/reset.css" rel="stylesheet">
<link href="/assets/img/favicon.png" rel="shortcut icon">
<!--[if lt IE 9]>
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<script src="http://code.jquery.com/jquery-latest.js"></script>
</head>
<body></body></html>
OBJECT;
return $template_create_object;
}
有没有一种方法可以改进 html 呈现给浏览器的方式,所以源代码看起来更好,而不是完全偏离它的外观,$template_create_object .= <<<OBJECT
并且有更好的方法将值从 index.php 传递到 template_object.php