0.1.1
由 Func::ubbcode()
方法升级而来
Ubbcode
namespace ginkgo;
class Ubbcode {
// 属性
public static $pairRules = array('strong', 'code', 'del', 'kbd', 'u', 'i', 'blockquote', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6');
public static $singleRules = array('hr', 'br');
public static $replaceRules = array(
'quote' => 'blockquote',
'b' => 'strong',
'em' => 'i',
's' => 'del',
);
public static $regexRules = array(
'/\[url\](.+?)\[\/url\]/i' => '<a href="$1" target="_blank">$1</a>',
'/\[url=(.+?)\](.+?)\[\/url\]/i' => '<a href="$1" target="_blank" title="$1">$2</a>',
'/\[img\](.+?)\[\/img\]/i' => '<img src="$1">',
'/\[img=(.+?)\](.+?)\[\/img\]/i' => '<img src="$1" alt="$2" title="$2">',
'/\[color=(.+?)\](.+?)\[\/color\]/i' => '<span style="color:$1">$2</span>',
'/\[bgcolor=(.+?)\](.+?)\[\/bgcolor\]/i' => '<span style="background-color:$1">$2</span>',
'/\[size=(.+?)\](.+?)\[\/size\]/i' => '<span style="font-size:$1">$2</span>',
);
// 方法
public static addPair( mixed $pair )
public static addSingle( mixed $single )
public static addReplace( mixed $src [, string $dst ] )
public static addRegex( mixed $src [, string $dst ] )
public static stripCode( string $string ) : string
public static convert( string $string ) : string
public static getImages( string $string [, mixed $options [, mixed $filter [, mixed $stristr ]]] ) : array
}
- | 权限 | 类型 | 描述 |
---|---|---|---|
属性 | - | - | - |
$pairRules |
public | static | 成对规则 |
$singleRules |
public | static | 单独规则 |
$replaceRules |
public | static | 替换规则 |
$regexRules |
public | static | 正则规则 |
方法 | - | - | - |
addPair() | public | static | 添加成对规则 |
addSingle() | public | static | 添加单独规则 |
addReplace() | public | static | 添加替换规则 |
addRegex() | public | static | 添加正则规则 |
stripCode() | public | static | 去除标签 |
convert() | public | static | 转换 ubbcode |
getImages() | public | static | 获取图片 |
addPair()
添加成对规则public static function addPair( mixed $pair )
参数
pair
规则,支持两种类型:字符串时、数组,为数组时表示批量添加返回
addSingle()
添加单独规则public static function addSingle( mixed $single )
参数
single
规则,支持两种类型:字符串时、数组,为数组时表示批量添加返回
addReplace()
添加替换规则public static function addReplace( mixed $replace [, string $dst ] )
参数
replace
规则,支持两种类型:字符串时、数组,为数组时表示批量添加dst
替换目标
当 replace
为字符串时,此参数为必需,为数组时自动忽略。
返回
addRegex()
添加正则规则public static function addRegex( mixed $regex [, string $dst ] )
参数
regex
规则,支持两种类型:字符串时、数组,为数组时表示批量添加dst
替换目标
当 regex
为字符串时,此参数为必需,为数组时自动忽略。
返回
stripCode()
去除标签public static function stripCode( string $string ) : string
参数
string
原始字符串返回
convert()
转换 ubbcodepublic static function convert( string $string ) : string
参数
string
原始字符串返回
getImages()
获取图片public static function getImages( string $string [, mixed $options [, mixed $filter [, mixed $stristr ]]] ) : array
参数
string
原始字符串options
php 语言中,pathinfo 函数的 options 参数filter
过滤参数(过滤包含指定字符的图片),支持两种类型:字符串时、数组,为数组时表示批量include
包含参数(取出包含指定字符的图片),支持两种类型:字符串时、数组,为数组时表示批量返回