Basic PHP development tutorial: Simple UBB text editor
If you don’t understand this section, you can skip it. If you are interested, you can read it carefully in the future
Let’s take a look at the UBB editor. This is a text processing technology often used on websites. Because of the use of the UBB file editor, the format we specified can exist. If the format is not specified, users cannot display it on the website.
Let’s take a look at the effect:
<?php $string='[b]静夜思[/b] [color=Red]李白[/color] [i]床前明月光[/i] [u]疑是地上霜[/u] [i]举头望明月[/i] [u]低头思故乡[/u] '; //匹配UBB字符 $pattern=array( '/\[b\](.*)\[\/b\]/i', '/\[i\](.*)\[\/i\]/iU', '/\[u\](.*?)\[\/u\]/i', '/\[color=(.*?)\](.*?)\[\/color\]/', ); //需要替换的UBB字符 $replace=array( '<b>\1</b><br />', '<i>\1</i><br />', '<u>\1</u><br />', '<font color="\1">\2</font><br />', ); //使用正则匹配$string,将$string当中的值变为$replace的效果 $ubb=preg_replace($pattern,$replace,$string); echo $ubb; ?>
The output result is shown on the right
new file
<?php
$string='[b]静夜思[/b]
[color=Red]李白[/color]
[i]床前明月光[/i]
[u]疑是地上霜[/u]
[i]举头望明月[/i]
[u]低头思故乡[/u]
';
//匹配UBB字符
$pattern=array(
'/\[b\](.*)\[\/b\]/i',
'/\[i\](.*)\[\/i\]/iU',
'/\[u\](.*?)\[\/u\]/i',
'/\[color=(.*?)\](.*?)\[\/color\]/',
);
//需要替换的UBB字符
$replace=array(
'<b>\\1</b><br />',
'<i>\\1</i><br />',
'<u>\\1</u><br />',
'<font color="\\1">\\2</font><br />',
);
//使用正则匹配$string,将$string当中的值变为$replace的效果
$ubb=preg_replace($pattern,$replace,$string);
echo $ubb;
?>
Preview
Clear
Students who have watched this course are also learning
Let's briefly talk about starting a business in PHP
Quick introduction to web front-end development
Large-scale practical Tianlongbabu development of Mini version MVC framework imitating the encyclopedia website of embarrassing things
Getting Started with PHP Practical Development: PHP Quick Creation [Small Business Forum]
Login verification and classic message board
Computer network knowledge collection
Quick Start Node.JS Full Version
The front-end course that understands you best: HTML5/CSS3/ES6/NPM/Vue/...[Original]
Write your own PHP MVC framework (40 chapters in depth/big details/must read for newbies to advance)















The courseware is not available for download at the moment. The staff is currently organizing it. Please pay more attention to this course in the future~ 