变量未定义是什么时候


Variable undefined when is it?

对我来说没有意义,为什么它不起作用,也许我很愚蠢或盲目,但我无法解决它。

注意:未定义的变量:info_table在文件中.php在第 35 行

这是它的代码...

<?php 
require_once("includes/connect.php"); 
include("includes/functions.php"); 
?>
**<?php 
if (isset($_GET['info'])){
    $info_table = $_GET['info'];
} elseif (isset($_GET['page'])){
    $page_table = $_GET['page'];
}
?>**
<?php include("includes/header.php"); ?>
    <div id="content">
        <table id="table">
            <tr>
                <td id="nav">
                    <ul class="info">
                        <?php 
                            $result = get_all_info();
                            while ($info = mysql_fetch_assoc($result)){
                                echo "<li><a href='"content.php?info=" . urlencode($info['id']) . "'">{$info["menu"]}</a></li>";
                            $result2 = get_pages_for_info($info['id']);
                                echo "<ul class='"pages'">";
                            while ($page = mysql_fetch_assoc($result2)){
                                echo "<li><a href='"content.php?page=" . urlencode($page['id']) . "'">{$page["menu"]}</a></li>";
                            }
                                echo "</ul>";
                            }
                        ?>
                    </ul>
                </td>
                <td id="main">
                    <h2>Main Content</h2>
                    **<?php echo $info_table; ?>**
                </td>
            </tr>
        </table>
    </div>
    <?php 
    include("includes/footer.php"); 
    ?>
</body>
</html>

你能帮忙吗?哈哈!

不要讨厌我使用表格,它是一个实验性和教育性的脚本,我编码。我不是亲(还!

非常感谢!

$infotable定义为 if 条件之外的空字符串

$info_table = "";
if (isset($_GET['info'])){
  $info_table = $_GET['info'];
}else...

这样,即使条件为 false,也定义了 $infotable(但是如果未设置获取信息,这将在 <td id="main"> 中打印空字符串)