我知道這個問題上有更多的話題,我已經閱讀了他們,但我沒有找到答案。PHP包含/未定義變量
我有一個index.php,包含一堆.php包括:header.php,navigation.php,box.php,footer.php,並且在「pages」div裏面,我有一個需要的不同(基於navbar.php或box.php的鏈接)。
navbar.php例如:
<a href="index.php?v=pag1.php">Page1</a>
<a href="index.php?v=pag2.php">Page2</a>
的index.php:
<div id="wrapper">
<div id="header">
<div id="topbox">
<?php include ("box.php"); ?>
</div></div>
<div id="content">
<div id="bara">
<div id="navbar">
<?php include ("navbar.php"); ?>
</div>
</div>
<div id="pages">
<?php include ("$v"); ?>
</div>
</div>
<div id="footer">
<?php include("footer.php"); ?>
</div>
</div>
我有一個$ V = 'pag1.php',$ V = 'pag2.php' 等上每一頁我想包括,但我得到「未定義的變量」錯誤「未定義的變量:v在C:\ wamp \ www \ test \ index.php在39行」
如果我定義變量$ v index.php,它的工作原理,但這意味着我將不得不創建重複o f index.php,並有點擊敗目的。我只希望pag1.php,pag2.php,pag3.php等包含在index.php中,而不是創建大量副本。我可以使用HTML的:)
我知道我可能會問一個愚蠢的問題,但我是一個PHP新手,我不知道在哪裏尋找答案。先謝謝你。
嘗試包括:($ V); –