我只是潛入PHP並一直在做一些閱讀和玩耍 - 我的代碼如下,我試圖加載頁面(正如你所看到的) - 我得到解析錯誤。開始PHP(加載DIV)
<?php include(''$id'') ?>
我告訴我的指數中的語法錯誤,unexpecter T_VARIABLE在第7行
7號線的index.php應該是變量,而不是( '的$ id')
當我在當前編碼中使用('$ id')或('$ nav_menu')時,它使我無法打開流:沒有這樣的文件或目錄
我可能錯過了明顯的東西,但有人能指引我走向正確的方向嗎?
感謝
<?php
if (is_numeric($_GET['id'])) //prevent hacking
{
switch ($_GET['id']) //get the id of menu needed for this page
{
case 0:
$nav_menu = "content.php"; //if the variable is 0 or not set
break;
case 1:
$nav_menu = "bio.php"; //if the variable is 1, get category 1 links
break;
case 2:
$nav_menu = "contact.php"; //if the variable is 2, get category 2 links
break;
default:
$nav_menu = "content.php"; //redundant for defaulting if the id is greater than 2
}
}
?>
btw爲什麼你曾經想在$ id變量周圍使用2對單引號? – luca 2011-05-28 21:59:52
@luca當你想包含文件'$ id.php'? :D它可能適用於Mac! – Halcyon 2011-05-28 22:17:43
@frits van Campen是啊!你是對的(我試過了= D) – luca 2011-05-28 22:34:21