调用一个php文件在div中不起作用

时间:2014-06-04 12:58:00

标签: php html

我有一个小项目,我正在使用标签内的表格。在最后一个表格中,我试图调用news.php文件,该文件将显示表格内的所有新闻,但此处未显示任何结果。任何人都可以知道我做错了吗?如何调用div里面的news.php文件?谢谢。 这是我的代码:

<?php
// -- REGISTER ERSTELLEN -------------------------------------------------------

$page['register-fahrzeuge'] = array(
    1   => array( 'Fahrzeug','aktiv',$page['script'],'',''),
    0   => array( 'Edit-Fahrzeug','aktiv',$page['script'],'',''),   
);

$page['register-news'] = array(
    1   => array( 'News','aktiv',$page['script'],'',''),
);



// -- HTML AUSGEBEN ------------------------------------------------------------
$page['content'] .= '

<table width="538" cellspacing="0" cellpadding="0" border="0" >
    <tr>
        <td>
            <div>'.CreateRegister($page['register-news']).'</div>
            '.CreateMessage().'
            <div class="cont-liste-verlauf register">
                <?php
                require ("news.php");
                ?>
            </div>
        </td>
    </tr>
</table>';
?>

3 个答案:

答案 0 :(得分:0)

你需要这样做:

$page['content'] .= '

<table width="538" cellspacing="0" cellpadding="0" border="0" >
    <tr>
        <td>
            <div>'.CreateRegister($page['register-news']).'</div>
            '.CreateMessage().'
            <div class="cont-liste-verlauf register">'.require ("news.php").' </div>
        </td>
    </tr>
</table>';

您无法再次在<?php标记内使用<?php标记,请将其删除

答案 1 :(得分:0)

按如下方式更改您的代码,

<?php
// -- REGISTER ERSTELLEN -------------------------------------------------------

$page['register-fahrzeuge'] = array(
    1   => array( 'Fahrzeug','aktiv',$page['script'],'',''),
    0   => array( 'Edit-Fahrzeug','aktiv',$page['script'],'',''),   
);

$page['register-news'] = array(
    1   => array( 'News','aktiv',$page['script'],'',''),
);



// -- HTML AUSGEBEN ------------------------------------------------------------
$page['content'] .= '

<table width="538" cellspacing="0" cellpadding="0" border="0" >
    <tr>
        <td>
            <div>'.CreateRegister($page['register-news']).'</div>
            '.CreateMessage().'
            <div class="cont-liste-verlauf register">'.

                require ("news.php").'

            </div>
        </td>
    </tr>
</table>';
?>

答案 2 :(得分:0)

我在定义php文件时犯了错误。这是答案:

$page['content'] .= '

<table width="538" cellspacing="0" cellpadding="0" border="0" >
    <tr>
        <td>
            <div>'.CreateRegister($page['register-news']).'</div>
            '.CreateMessage().'
            <div class="cont-liste-verlauf register">'.require ("news.php").' </div>
        </td>
    </tr>
</table>';