Home > Backend Development > PHP Tutorial > 如何组装一个模版?

如何组装一个模版?

WBOY
Release: 2016-06-23 14:16:25
Original
806 people have browsed it

写了许多function和class,分别保存在若干个php文件里。
如a.php

function my_trim($text){
  return strip_tags(trim($text));
}

现在有一个index.php页面,如何加载这些function和class,用include,requre_once,require,哪种耗资源最少,效率最高?

另外,如果网站支持多语言,在index.php里如何加载语言文件,语言文件的保存格式是什么?也是include,requre_once,require?如何替换function和class里的翻译文字?


回复讨论(解决方案)

include_once/require_once 不推荐使用这种习惯,推荐自行判断是否已include
include 如果出错,仍然会继续执行
require 如果出错,会产生致命错误,中止执行后面的代码

还有呢?继续给些指点吧。

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template