请问这段php代码哪里有问题😅

这是我给一个开源项目写的一个扩展中的代码,下面第一段代码可以正确运行,但是因为需要更多功能,我就写了下面的第二段代码,但是这个就无法达到创建一个iframe的BBcode的目的,烦请各位帮我看下,谢谢。(如需跟多信息请告知😅)

return [ 
  (new Extend\Frontend('forum'))
  ->css(__DIR__.'/less/forum.less'),
    (new Extend\Formatter)
    ->configure(function (Configurator $config) {
         $config->BBCodes->addCustom(
           '[iframe={URL}]',
           '
class="iframe">
' ); }) ];
return [ 
  (new Extend\Frontend('forum'))
  ->css(__DIR__.'/less/forum.less'),
    (new Extend\Formatter)
    ->configure(function (Configurator $config) {
         $config->BBCodes->addCustom(
           '[iframe={URL}{width}{height}{fr}{ma}{mh}{scro}]',
           '<div class="iframe">
           <iframe 
             src="{URL}"
             width="{width}"
             height="{height}"
             frameborder="{fr}"
             marginwidth="{ma}"
             marginheight="{mh}"
             vspace="0"
             hspace="0"
             allowtransparency="true"
             scrolling="{scro}"
             allowfullscreen="true"
           >
           iframe>
         div>'
        );
    })
];


回答不易,求求您采纳点赞哦

看起来问题出在您添加到格式化程序配置中的 BBCode。您添加的自定义 BBCode 缺少一些属性并且格式不正确。

The problem is the missing = after {URL} and {width} and {height} and {fr} and {ma} and {mh} and {scro}, it should be like this [iframe={URL}={width}={height}={fr}={ma}={mh}={scro}]

它应该是这样的:

$config->BBCodes->addCustom(
    '[iframe={URL}={width}={height}={fr}={ma}={mh}={scro}]',
    '<div class="iframe">
    <iframe 
        src="{URL}"
        width="{width}"
        height="{height}"
        frameborder="{fr}"
        marginwidth="{ma}"
        marginheight="{mh}"
        vspace="0"
        hspace="0"
        allowtransparency="true"
        scrolling="{scro}"
        allowfullscreen="true"
    >
    </iframe>
    </div>'
);

此外,您可以考虑使用 iframe 属性,例如以百分比而不是像素表示的宽度和高度,这样 iframe 将采用父容器的宽度和高度。