今天看了下正则表达式,忽然觉得可以把我现在手上的企业建站系统改一下。不过改来改去觉得还是仿dede的方式好一点。 /({t:*[^{]*\/}|{t:*[^}]*}([^{]|(?R))*{\/t:.*?})/i 但是对我于这个系统来说,那就简单得多,所以参照这个我做了以下的正则表达式 private
今天看了下正则表达式,忽然觉得可以把我现在手上的企业建站系统改一下。不过改来改去觉得还是仿dede的方式好一点。
/({t:*[^{]*\/}|{t:*[^}]*}([^{]|(?R))*{\/t:.*?})/i
private $preg_string = "/(<m:*[^<]*>|<\/m:*[^<]*>)/si";
$tag_arr数组的格式如下

然后用PHP的str_replace方式替换$tag_arr['str']
Difeye是一款超轻量级PHP框架,主要特点有: Difeye是一款超轻量级PHP框架,主要特点有: ◆数据库连接做自动主从读写分离配置,适合单机和分布式站点部署; ◆支持Smarty模板机制,可灵活配置第三方缓存组件; ◆完全分离页面和动作,仿C#页面加载自动执行Page_Load入口函数; ◆支持mysql,mongodb等第三方数据库模块,支持读写分离,分布式部署; ◆增加后台管理开发示例
0
以下是源码
立即学习“PHP免费学习笔记(深入)”;
stemplate.class.php
<?php
require './stemplate.class.php';
$template = new stemplate();
$template->display('index.htm');<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gbk" />
<title>模板</title>
</head>
<body>
<b>正常输出</b><br/>
<?php echo '正常的PHP输出'; ?><br/>
<b>foreach循环</b><br/>
<?php $temp_arr = array('aa' , 'bbb'); ?>
<m:foreach from='$temp_arr' value='cc'>
<td><m:field name='cc' /></td>
</m:foreach>
</body>
</html><?php
class m{
public function _foreach($property=null){
$from = $property['from'];
$value = $property['value'];
$content = "<?php foreach($from as \$$value){ ?>";
return $content;
}
public function _field($property=null){
return "<?php echo \${$property['name']}; ?>";
}
}
PHP怎么学习?PHP怎么入门?PHP在哪学?PHP怎么学才快?不用担心,这里为大家提供了PHP速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号