Home > php教程 > php手册 > PHP模板二(仿DEDE)

PHP模板二(仿DEDE)

WBOY
Release: 2016-06-06 20:00:08
Original
1321 people have browsed it

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

今天看了下正则表达式,忽然觉得可以把我现在手上的企业建站系统改一下。不过改来改去觉得还是仿DEDE的方式好一点。

/({t:*[^{]*\/}|{t:*[^}]*}([^{]|(?R))*{\/t:.*?})/i
Copy after login
但是对我于这个系统来说,那就简单得多,所以参照这个我做了以下的正则表达式

 

private $preg_string = "/(<m:>|)/si";</m:>
Copy after login


 

Copy after login
Copy after login

$tag_arr数组的格式如下

PHP模板二(仿DEDE)

然后用PHP的str_replace方式替换$tag_arr['str']

以下是源码

stemplate.class.php

Copy after login
Copy after login

index.php
<?php require './stemplate.class.php';

$template = new stemplate();

$template->display('index.htm');
Copy after login

index.htm


<meta http-equiv="Content-Type" content="text/html; charset=gbk">
<title>妯℃澘</title>



<b>姝e父杈撳嚭</b><br>
<?php echo '姝e父鐨凱HP杈撳嚭'; ?><br>
<b>foreach寰</b>
Copy after login
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 Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template