Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/272.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 尝试使用Thunder/shortcode解析短代码_Php_Twitter Bootstrap_Parsing_Shortcode - Fatal编程技术网

Php 尝试使用Thunder/shortcode解析短代码

Php 尝试使用Thunder/shortcode解析短代码,php,twitter-bootstrap,parsing,shortcode,Php,Twitter Bootstrap,Parsing,Shortcode,我正在尝试向所见即所得添加短代码。我正在使用。我试图将其解析为: 我的代码如下所示: use Thunder\Shortcode\HandlerContainer\HandlerContainer; use Thunder\Shortcode\Parser\RegularParser; use Thunder\Shortcode\Processor\Processor; use Thunder\Shortcode\Shortcode\ShortcodeInterface; function p

我正在尝试向所见即所得添加短代码。我正在使用。我试图将其解析为:

我的代码如下所示:

use Thunder\Shortcode\HandlerContainer\HandlerContainer;
use Thunder\Shortcode\Parser\RegularParser;
use Thunder\Shortcode\Processor\Processor;
use Thunder\Shortcode\Shortcode\ShortcodeInterface;

function processAgendaContent($content)
{

    $handlers = new HandlerContainer();
    $handlers->add('panel', function(ShortcodeInterface $s) {
        return "<div class=\"panel panel-default\">";
    });

    $handlers->add('header', function(ShortcodeInterface $s) {
        return '
    <h4 class="panel-title">
    <a href="#collapse1" target="_blank" role="button" data-toggle="collapse" aria-expanded="true" aria-controls="collapse1" class="btn-collapse">
    ' . $s->getContent() . '</a>
    </h4>';

    });

    $processor = new Processor(new RegularParser(), $handlers);

    echo $processor->process($content);
使用Thunder\Shortcode\HandlerContainer\HandlerContainer;
使用Thunder\Shortcode\Parser\RegularParser;
使用Thunder\Shortcode\Processor\Processor;
使用Thunder\Shortcode\Shortcode\Shortcode接口;
函数processAgendaContent($content)
{
$handlers=newhandlerContainer();
$handlers->add('panel',函数(ShortcodeInterface$s){
返回“”;
});
$handlers->add('header',函数(ShortcodeInterface$s){
返回'
';
});
$processor=新处理器(新的RegularParser(),$handlers);
echo$processor->process($content);

我现在的问题是,当我试图解析时,它解析的是开始标记,而不是结束标记,因此我认为getContent()不起作用。知道我做错了什么吗?谢谢,我是短代码库的作者。要解决问题,请将
面板
短代码处理程序主体更改为:

return '<div class="panel panel-default">'.$s->getContent().'</div>';
返回“”。$s->getContent();
每个短代码处理程序都控制从整个短代码文本返回的内容。您只返回了一个简单的字符串,没有在任何地方包含其内容,这就是为什么被
[panel]
封装的整个文本被丢弃的原因

我希望这有助于更好地理解这个库是如何工作的,如果您有更多的问题,我将在这里愉快地回答

return '<div class="panel panel-default">'.$s->getContent().'</div>';