search
Homephp教程php手册PHP模板二(仿DEDE)

PHP模板二(仿DEDE)

Jun 06, 2016 pm 08:00 PM
dedephptemplateregularexpression

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

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

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

 

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


 



$tag_arr数组的格式如下

PHP模板二(仿DEDE)

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

以下是源码

stemplate.class.php



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

$template = new stemplate();

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

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>
Statement
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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Safe Exam Browser

Safe Exam Browser

Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

DVWA

DVWA

Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

EditPlus Chinese cracked version

EditPlus Chinese cracked version

Small size, syntax highlighting, does not support code prompt function

VSCode Windows 64-bit Download

VSCode Windows 64-bit Download

A free and powerful IDE editor launched by Microsoft