中考之前不改名 2023-01-26 16:44 采纳率: 47.4%
浏览 50

请问这段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}]',
           '<div class="iframe">
           <iframe 
             src="{URL}"
             width="100%"
             height="600"
             frameborder="0"
             marginwidth="0"
             marginheight="0"
             vspace="0"
             hspace="0"
             allowtransparency="true"
             scrolling="true"
             allowfullscreen="true"
           >
           </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>'
        );
    })
];


  • 写回答

1条回答 默认 最新

  • 快撑死的鱼 2023-01-26 19:19
    关注

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

    看起来问题出在您添加到格式化程序配置中的 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 将采用父容器的宽度和高度。

    评论

报告相同问题?

问题事件

  • 创建了问题 1月26日

悬赏问题

  • ¥60 大一项目课,微信小程序
  • ¥15 求视频摘要youtube和ovp数据集
  • ¥15 怎么改成输入一个要删除的数后现实剩余的数再输入一个删除的数再现实剩余的数用yes表示继续no结束程序
  • ¥15 在启动roslaunch时出现如下问题
  • ¥15 汇编语言实现加减法计算器的功能
  • ¥20 关于多单片机模块化的一些问题
  • ¥30 seata使用出现报错,其他服务找不到seata
  • ¥35 引用csv数据文件(4列1800行),通过高斯-赛德尔法拟合曲线,在选取(每五十点取1点)数据,求该数据点的曲率中心。
  • ¥20 程序只发送0X01,串口助手显示不正确,配置看了没有问题115200-8-1-no,如何解决?
  • ¥15 Google speech command 数据集获取