当前位置:首页 » 编程语言 » php模板网站

php模板网站

发布时间: 2023-05-20 02:50:14

php程序的网站,模版在哪里

问题比较笼统呀
你先说清楚你用的什么框架,ThinkPhp?
应该是了,用的比较多。MVC模式的
模型就是moudle了,去Model文件夹找;
控制器就是controller,也就是存入类文件的;
视图就是View,就是页面;

❷ 如何使用php网站模板

这问的太广泛了

❸ 做个网站(php的),用许多的页面有相同的部分,如导航条之类的,想做个模板,问下怎么做,怎么加载

可以在php中先:
include($tpl->template('滑嫌唯moban.html'));

然后再再php中加载个Template.php 就可以了。
Template.php 代码如下:
<?php

class Template
{
public $templateDir = 'templates';
public $leftTag = '{';
public $rightTag = '}';
public $compileDir = 'cache';
public $compiledFileExt = '.TemplateCompiled.php';
public $templateFileExt = '.html'; //当display() cache() 不使用参数时使用
public $caching = false;
public $cacheDir = 'cache';
public $cacheDirLevels = 0; /者迹/信培缓存目录层次
public $cacheFileExt = '.TemplateCache.php';
public $cacheLifeTime = 3600; // 单位 秒
public $cacheID;
public $forceCompile = false;
public $lang=array();

private $cacheFile; //缓存文件,在_saveCache()中使用
private $realCacheID; //通过计算得出的缓存ID

const MAX_CACHE_DIR_LEVELS=16; //最大缓存目录层次数量

public function __construct($arrConfig = array())
{
foreach ($arrConfig as $key=>$val) {
$this->$key = $val;
}

if ($this->cacheDirLevels>self::MAX_CACHE_DIR_LEVELS) {
$this->cacheDirLevels=self::MAX_CACHE_DIR_LEVELS;
}
}

/**
* 判断缓存文件是否有效
*
* @param string $file
* @param string $cacheID
* @return boolean
*/
public function cached($file='',$cacheID='')
{
$file=$this->getTemplateFile($file);
$this->cacheID=$cacheID;
$cachefile=$this->getCacheFileName($file,$cacheID);
if ($this->caching && is_file($cachefile) && (filemtime($cachefile)+$this->cacheLifeTime)>time()) {
return true;
} else {
return false;
}
}

/**
* 返回模板文件完整路径
*
* @param string $file
* @return string
*/
private function getTemplateFile($file='')
{
if (!strlen($file)) {
$file=App::$controller.'_'.App::$action.$this->templateFileExt;
}
return $file;
}

/**
* 获取缓存文件完整路径
*
* @param string $file
* @param string $cacheID
* @return string
*/
private function getCacheFileName($file,$cacheID)
{
if (!strlen($this->realCacheID)) {
$this->realCacheID=$cacheID!=''?$cacheID:$_SERVER['SCRIPT_NAME'].$_SERVER['QUERY_STRING'];
$this->realCacheID.=$this->templateDir.$file.APP_NAME;
}
$md5id=md5($this->realCacheID);
$this->cacheDirLevel=$this->getCacheDirLevel($md5id);
return $this->cacheDir.$this->cacheDirLevel.'/'.$md5id.$this->cacheFileExt;
}

/**
* 获取缓存目录层次
*
*/
private function getCacheDirLevel($md5id)
{
$levels=array();
$levelLen=2;
for ($i=0; $i<$this->cacheDirLevels; $i++) {
$levels[]='TepmlateCache_'.substr($md5id,$i*$levelLen,$levelLen);
}
return !count($levels) ? '' : '/'.implode('/',$levels);
}

/**
* 在$this->compile()中替换$foo.var为数组格式$foo['var']
*
*/
private function compile_replace($str)
{
$str=preg_replace('/(\$[a-z_]\w*)\.([\w]+)/',"\\1['\\2']",$str);
return $this->leftTag.$str.$this->rightTag;
}

/**
* 编译模板文件
*
* @param string $file
* @return string
*/
private function compile($file='')
{
$file=$this->getTemplateFile($file);
$fullTplPath=$this->templateDir.'/'.$file;
$compiledFile=$this->compileDir.'/'.md5($fullTplPath).$this->compiledFileExt;
if ($this->forceCompile || !is_file($compiledFile) || filemtime($compiledFile)<=filemtime($fullTplPath)) {
$content=file_get_contents($fullTplPath);
$leftTag=preg_quote($this->leftTag);
$rightTag=preg_quote($this->rightTag);
$search=array(
'/'.$leftTag.'include ([\w\.\/-]+)'.$rightTag.'/i', //导入子模板
'/'.$leftTag.'(\$[a-z_]\w*)\.(\w+)'.$rightTag.'/i', //将模板标签{$foo.var}修改为数组格式{$foo['var']}
'/'.$leftTag.'(.+?\$[a-z_]\w*\.\w+.*?)'.$rightTag.'/ie', //将模板标签中的$foo.var修改为数组格式$foo['var']
'/'.$leftTag.'(else if|elseif) (.*?)'.$rightTag.'/i',
'/'.$leftTag.'for (.*?)'.$rightTag.'/i',
'/'.$leftTag.'while (.*?)'.$rightTag.'/i',
'/'.$leftTag.'(loop|foreach) (.*?) as (.*?)'.$rightTag.'/i',
'/'.$leftTag.'if (.*?)'.$rightTag.'/i',
'/'.$leftTag.'else'.$rightTag.'/i',
'/'.$leftTag."(eval) (.*?)".$rightTag.'/is',
'/'.$leftTag.'\/(if|for|loop|foreach|while)'.$rightTag.'/i',
'/'.$leftTag.'((( *(\+\+|--) *)*?(([_a-zA-Z][\w]*\(.*?\))|\$((\w+)((\[|\()(\'|")?\$*\w*(\'|")?(\)|\]))*((->)?\$?(\w*)(\((\'|")?(.*?)(\'|")?\)|))){0,})( *\.?[^ \.]*? *)*?){1,})'.$rightTag.'/i',
'/'.$leftTag.'\%([\w]+)'.$rightTag.'/', //多语言
);
$replace=array(
'<?php include($tpl->template("\\1"));?>',
$this->leftTag."\\1['\\2']".$this->rightTag,
"\$this->compile_replace('\\1')",
'<?php }else if (\\2){ ?>',
'<?php for (\\1) { ?>',
'<?php $__i=0; while (\\1) {$__i++; ?>',
'<?php $__i=0; foreach ((array)\\2 as \\3) { $__i++; ?>',
'<?php if (\\1){ ?>',
'<?php }else{ ?>',
'<?php \\2; ?>',
'<?php } ?>',
'<?php echo \\1;?>',
'<?php echo $this->lang["\\1"];?>',
);
$content=preg_replace($search,$replace,$content);
file_put_contents($compiledFile,$content,LOCK_EX);
}
return $compiledFile;
}

/**
* 根据是否使用缓存,输出缓存文件内容
*
* @param string $tplFile
* @param string $cacheID
*/
public function cache($tplFile,$cacheID='')
{
$this->cacheID=$cacheID;
$cacheFile=$this->getCacheFileName($file,$cacheID);
if ($this->cached($file,$cacheID)) {
readfile($cacheFile);
exit;
} elseif ($this->caching) {
ob_start(array(&$this,'_saveCache'));
$this->cacheFile=$cacheFile;
}
}

/**
* 返回编译后的模板文件完整路径
*
* @param string $file
* @return string
*/
public function template($file='')
{
$file=$this->getTemplateFile($file);
return $this->compile($file);
}

/**
* 回调函数,供cache()函数使用
*
* @param string $output
* @return string
*/
public function _saveCache($output)
{
$cacheDir=$this->cacheDir.$this->cacheDirLevel;
is_dir($cacheDir) or mkdir($cacheDir,0777,true);
file_put_contents($this->cacheFile,$output,LOCK_EX);
return $output;
}

}//end class

❹ 怎么用php模板搭建网站

1:首先看使用的模版是哪种CMS的
2:蔽粗枝织梦的凳雹(dede)?帝国的?eshop?或者是其他的CMS
3:找到对应的CMS程序宏敏
然后下载相应的CMS程序安装就可以了

❺ 现在有一个HTML的网页,要怎么变成模板,用php把这个网站搭建出来

如果要把html转成cms模板,那是仿站的过程,比直接从千站素材下载模板复杂的多。原理大致为对html网页根据CMS系统程序的不同,对模板标签的定义改造:

比如有些模板用${news[1,2,3,3]}有的类似 {FS_新闻列表}

等形式,楼主应该根据CMS程序的使用说明,了解模板标签,在你的页面中插入相应的标签后,将代码复制到程序模板目录或后台..

❻ 用PHP制作静态网站模板,什么是PHP呀,请指教!

这是一个用模板生成HTML的实例,自己摸索一下.
<?php
require('smarty/Smarty.class.php');
$t = new Smarty;
$t->assign("title","Hello World!");
$content = $t->fetch("templates/index.htm");
//这里的 fetch() 就是获取输出内容的函数,现在$content变量里面,就是要显示的内容了
$fp = fopen("archives/2005/05/19/0001.html", "w");
fwrite($fp, $content);
fclose($fp);
?>

什么是衫和PHP...

PHP是一个基于服务端来创建动态网站的脚本语言,您可以用PHP和HTML生成网站主页。当一个访问者打差乎开主页时,服务端便执行PHP的命令并将执行结果发送至访问者的浏览器中,这类似于ASP和CoildFusion,然而PHP和他们不同之处在于PHP开虚塌悉放源码和跨越平台,PHP可以运行在WINDOWS NT和多种版本的UNIX上。它不需要任何预先处理而快速反馈结果,它也不需要mod_perl的调整来使您的服务器的内存映象减小。PHP消耗的资源较少,当PHP作为Apache Web服务器一部分时,运行代码不需要调用外部二进制程序,服务器不需要承担任何额外的负担。

❼ 用PHP制作静态网站的模板框架(二)

PHP代码全部保存到单独的文件中,这个文件也就是由页面URL实际调用的文件。Web服务器通过PHP引擎解析该文件,然后把结果返回给浏览器。一般地,PHP代码总是动态地生成页面内容,比如查询数据库或者执行某种计算等。下面是一个例子:
<?php
//
example.php
require('class.FastTemplate.php');
$tpl
=
new
FastTemplate('.');
$tpl->define(
array(
'main'
=>
'main.htm',
'header'
=>
'header.htm',
'leftnav'
=>
'leftnav.htm'
)
);
//
此处的PHP代码设置$content使其包含合适的页面内容
$tpl->assign('CONTENT',
$content);
$tpl->parse('HEADER',
'header');
$tpl->parse('LEFTNAV',
'leftnav');
$tpl->parse('MAIN',
'main');
$tpl->FastPrint('MAIN');
?>

这里我们使用的是流行的FastTemplate模板类,但其基本思路对于其他许多模板类来说都一样。首先你实例化一个类,告诉它到哪里去寻找模板文件以及哪一个模板文件与页面的哪部分对应;接下来是生成页面内容,把结果赋予内容的标识符;然后,依次解析各个模板文件,模板类将执行必要的替换操作;最后把解析结果输出到浏览器。

这个文件完全由PHP代码构成,不包含任何HTML代码,这是它最大的优点。现在,PHP程序员可以集中精力编写生成页面内容的代码,而不必为了如何生成HTML去正确地格式化最终页面而担心。

你可以使用这种方法和上面的文件构造出一个完整的网站。如果PHP代码是以URL中的查询字符串为基础生成页面内容,例如http://www.foo.com/example.php?article=099,你可以据此构造出一个完整的杂志网站。

很容易看出采用模板还有第二个好处。如上例所示,页面左边的导航条单独保存为一个文件,我们只需编辑这一个模板文件就可以改变网站所有页面左边的导航条。

❽ 如何使用PHP网站模板

看smarty手册

❾ 用PHP模板做的网站,如何上传到租用的万网空间服务器上

1、找你空间服务商,给你一个FTP地址。

2、下载一个FTP工具,通常用Flashfxp

LeapFTP,个人认为Flashfxp比LeapFTP好用。

3、打开FTp软件。出现一个界面。当然,两个界面有所不同,但都大同小异。

4、找开菜单栏的“站点”,打开,选择“新建站点”。

5、输入空间服务商给你的FTP用户名和密码。

6、连接。(找到wwwroot或web文件夹,通常为这两个,打开它。如果是首次上伟可以把里面的文件全删除掉)

连接成功后会分为左右两个界面(一个为本地浏览器,一个为FTP浏览器)。然后在本地浏览器找到你需要上传的文件。选中。可以全选,右键,这时会出现一个菜单。你再点传送即可。

如果发现有文件在上传过程中丢失,可以点传送,再选择续传。Flashfxp 比
LeapFTP较方便。

剩下的自己去摸索吧。

谢谢

❿ 前端模板、后台模板和PHP源码功能demo下载的网站都有哪些好的呢,PHP100、erdangjiade、兄弟连还有哪些

还有thinkphp官网,或者一些其他的培训PHP的,网站都是可以下载到的。

热点内容
汽车配置物品怎么处理 发布:2025-05-20 07:47:23 浏览:225
怎么修改华为wifi密码 发布:2025-05-20 07:45:12 浏览:41
php函数递归 发布:2025-05-20 07:39:36 浏览:781
登陆认证失败请检查服务器地址 发布:2025-05-20 07:06:55 浏览:831
无限分类实现php 发布:2025-05-20 06:57:40 浏览:681
数据结构c语言版严蔚敏李冬梅 发布:2025-05-20 06:55:05 浏览:449
iphone快捷访问 发布:2025-05-20 06:55:05 浏览:929
如何加密硬盘分区 发布:2025-05-20 06:52:29 浏览:363
反编译gd 发布:2025-05-20 06:52:23 浏览:838
java源码知乎 发布:2025-05-20 06:47:59 浏览:483