和我以前发的那种方法在本质上没有区别。
建立四个文件:total.class.php
test.php
test.tpl.phptotal.class.php内容如下:class display_t
{
function head(){
require('head.php');
}
function foot(){
require('foot.php');
}
}
test.php内容如下:
require('total.class.php');
class display extends display_t
{
function somecontents(){
return 'somecontents';
}
}
require('test.tpl.php');
$display=new display;test.tpl.php内容如下:
<html>
<head></head>
<body>
<?php $display->head(); ?><?php echo $display->somecontents();?><?php $display->foot();?>
</body>
</html>
建立四个文件:total.class.php
test.php
test.tpl.phptotal.class.php内容如下:class display_t
{
function head(){
require('head.php');
}
function foot(){
require('foot.php');
}
}
test.php内容如下:
require('total.class.php');
class display extends display_t
{
function somecontents(){
return 'somecontents';
}
}
require('test.tpl.php');
$display=new display;test.tpl.php内容如下:
<html>
<head></head>
<body>
<?php $display->head(); ?><?php echo $display->somecontents();?><?php $display->foot();?>
</body>
</html>
解决方案 »
- ThinkPHP 台代码动态修改config.php中的配置信息
- 开启php_zip.dll方法
- PHP对比MD5密码遇到问题!
- 查找关于php的教学视频
- 一个简单的类,都来看看
- 请问大家php或者script下有没有能让pc喇叭发声的脚本?
- Fatal error: Call to a member function on a non-object in D:\cart\showcart.php on line 56
- 通过<FORM>传递的字符串,字符串怎么会加了个\ ???
- 请问如何把数据导成文本生成在某个路径下。
- 熟悉GD的朋友进来一下!
- bin2hex函数的逆过程是什么函数?
- 如何从ASP的页面连接到PHP页面,再从PHP的页面连接到ASP页面?
test.php里面最后两行写反了另外,为了保证效率,在test.tpl.php中显示包含文件前面没有 echo ,而是直接require,感觉有些不统一,不知道大家有些什么好方法?用file_get_contents()比用require()可能要差不少吧??另外只体现思想,代码没有测试。