Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/user-interface/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php cms的简化语法_Php_User Interface - Fatal编程技术网

Php cms的简化语法

Php cms的简化语法,php,user-interface,Php,User Interface,我提供了一个小的php+mysql CMS的网站,将由业主更新。 正如WordPress上看到的,我想让用户有机会使用以下语法进行更复杂的更新: [row h="100"] [col link="/some/link/1"][/col] [col link="/some/link/2"][/col] [col link="/some/link/3"][/col] [/row] [el id="some-id"][/el] 显然,我的CMS必须以正常的完整html阅读和

我提供了一个小的php+mysql CMS的网站,将由业主更新。 正如WordPress上看到的,我想让用户有机会使用以下语法进行更复杂的更新:

[row h="100"]
    [col link="/some/link/1"][/col]
    [col link="/some/link/2"][/col]
    [col link="/some/link/3"][/col]
[/row]

[el id="some-id"][/el]
显然,我的CMS必须以正常的完整html阅读和翻译这个脚本。 当然,我可以用许多按正确顺序编写的replace()来完成这项工作,但我想这是一种更好、更可靠的方法


你有什么建议?这种语法是如何命名的?

根据您的需要调整它

function bbc2html($content) {
    $search = array (
        '/(\[b\])(.*?)(\[\/b\])/',
        '/(\[i\])(.*?)(\[\/i\])/',
        '/(\[u\])(.*?)(\[\/u\])/',
        '/(\[ul\])(.*?)(\[\/ul\])/',
        '/(\[li\])(.*?)(\[\/li\])/',
        '/(\[url=)(.*?)(\])(.*?)(\[\/url\])/',
        '/(\[row h=\")(.*?)(\\"])(.*?)(\[\/row\])/',
        '/(\[col link=\")(.*?)(\\"])(.*?)(\[\/col\])/'
    );

    $replace = array (
        '<strong>$2</strong>',
        '<em>$2</em>',
        '<u>$2</u>',
        '<ul>$2</ul>',
        '<li>$2</li>',
        '<a href="$2" target="_blank">$4</a>',
        '<div class="row" style="height: $2px;">$4</div>',
        '<a class="column" href="$2">$4</a>'
    );

     return preg_replace($search, $replace, $content);
}

echo bbc2html('[row h="100"][col link="/some/link/1"]test 1[/col][col link="/some/link/2"]test 2[/col][col link="/some/link/3"]test 3[/col][/row][el id="some-id"][/el]');
函数bbc2html($content){
$search=array(
“/(\[b\])(.*)(\[\/b\])/”,
“/(\[i\])(.*)(\[\/i\])/”,
“/(\[u\])(.*)(\[\/u\])/”,
“/(\[ul\])(.*)(\[\/ul\])/”,
“/(\[li\])(.*)(\[\/li\])/”,
“/(\[url=)(.*)(\])(.*)(.*)(\[\/url\])/”,
“/(\[行h=\”)(.*?(\\”])(.*?(\[\/行\])/”,
“/(\[col link=\”)(.*?(\\”])(.*?(\[\/col\])/”
);
$replace=数组(
“$2”,
'$2',
'$2',
“
    $2
”, “
  • 2美元”, '', '$4', '' ); 返回preg_replace($search,$replace,$content); } 回显bbc2html('[row h=“100”][col link=“/some/link/1”]测试1[/col][col link=“/some/link/2”]测试2[/col col][col col link=“/some/link/3”]测试3[/col col row][el id=“some id”][/el]);

  • 为bbc2html()提供一个不带空格的字符串。

    还没有。正如我所写的,我的理论是我可以通过许多stru_replace()来管理它,但对我来说这似乎不是最好的方法。酷的系统!谢谢你。