dongyishen5796 2016-11-03 16:05
浏览 62

使用PHP脚本的PHPBB自定义BBC代码?

With PHPBB is it possible to use PHP scripts with custom BBCodes?

An example use would be if i wanted to grab today's weather with Curl and then display it on a forum post as text data.

I have tried to add php code directly in the BBCode but it does not work, i have also tried to return an echo from JS but it didn't seem to work either.

I also tried this but it did not work:

<!-- PHP --><?php echo 'hello'; ?><!-- ENDPHP -->

How would i run some PHP code in a custom BBCode?

  • 写回答

1条回答 默认 最新

  • douchui4815 2016-11-04 11:47
    关注

    Still not sure I fully understand the question but:

    According to http://php.net/manual/en/function.bbcode-create.php you can add a content handling callback, e.g.:

    $BBHandler = bbcode_create([        
        'abc'=> [ 'type' => BBCODE_TYPE_NOARG, 
                   'open_tag'=>'<p>',
                   'close_tag'=>'</p>',
                   'content_handling' => function () { return "hello"; }
                ]
    ]);
    
    echo bbcode_parse($BBHandler,"[abc][/abc] word"); //"Should" echo hello world
    

    I am basing this on the PHP BBCode module

    评论

报告相同问题?