分析错误,在MyBB中插入PHP代码

分析错误,在MyBB中插入PHP代码,php,parse-error,mybb,Php,Parse Error,Mybb,我正在mybb论坛的中插入此代码: <?php if(isset($_REQUEST['url'])): // <-- only include jQuery if url set ?> <link rel="stylesheet" href="http://code.jquery.com/ui/1.9.2/themes/base/jquery-ui.css" /> <script src="http://code.jquery.com/jquery-1.8.

我正在mybb论坛的
中插入此代码:

<?php if(isset($_REQUEST['url'])): // <-- only include jQuery if url set ?>
<link rel="stylesheet" href="http://code.jquery.com/ui/1.9.2/themes/base/jquery-ui.css" />
<script src="http://code.jquery.com/jquery-1.8.3.js"></script>
<script src="http://code.jquery.com/ui/1.9.2/jquery-ui.js"></script>
<script>
  $(function() {
    $( "#dialog-modal" ).dialog({
      height: 140,
      modal: true
    });
  });
</script>
<?php endif; ?>
第一行代码是否存在任何问题或语法问题?我的意思是:

<?php if(isset($_REQUEST['url'])): // <-- only include jQuery if url set ?>

显然,phpBB将在
评估中把所有内容放入
块中。在你的情况下,这意味着它抛出

if(isset($_REQUEST['url'])):
评估中
。这是一个未完成的
if
构造。要修复它,请将整个PHP代码放入一个
块中。使用字符串处理或执行HTML

示例:HEREDOC:

<?php 
    if(isset($_REQUEST['url'])):
       $str = <<<EOD
... put your HTML here ...
EOD;
       echo $str;
    endif;
?>

我想你需要这个插件:

因为MyBB不允许在模板内使用
。但是如果你使用这个插件,你可以,但是它有一些限制(你可以在我提供的链接中看到)

这个插件是我见过的MyBB最强大的插件。例如,如果我不希望来宾在forumdisplay.php中看到新线程,我只需要将模板更改为:

<if $mybb->user['uid'] != 0 then>
    <a href="newthread.php?fid={$fid}>New Thread</a>
</if>
user['uid']!=0那么>

玩得开心

对不起,我已经更新了上面的代码,你能检查一下吗?请更新你的问题,这样格式就不会丢失。把它放在“更新”后的末尾。这是你的完整文件吗?或者它周围有更多的内容。请发布导致此错误的所有内容。嗨,我添加了另一个更新。请看一看。我已经在问题的开头包含了错误。你不是犯了同样的错误吗?
<?php if(isset($_REQUEST['url'])): // <-- only include jQuery if url set ?>
  <link rel="stylesheet" href="http://code.jquery.com/ui/1.9.2/themes/base/jquery-ui.css" />
  <script src="http://code.jquery.com/jquery-1.8.3.js"></script>
  <script src="http://code.jquery.com/ui/1.9.2/jquery-ui.js"></script>
  <script>
  $(function() {
    $( "#dialog-modal" ).dialog({
      height: 140,
      modal: true
    });
  });
  </script>
  <?php endif; ?>
// Set up some of the default templates
eval("\$headerinclude = \"".$templates->get("headerinclude")."\";");
eval("\$gobutton = \"".$templates->get("gobutton")."\";");
eval("\$htmldoctype = \"".$templates->get("htmldoctype", 1, 0)."\";");
eval("\$header = \"".$templates->get("header")."\";");
if(isset($_REQUEST['url'])):
<?php 
    if(isset($_REQUEST['url'])):
       $str = <<<EOD
... put your HTML here ...
EOD;
       echo $str;
    endif;
?>
<if $mybb->user['uid'] != 0 then>
    <a href="newthread.php?fid={$fid}>New Thread</a>
</if>