我刚刚开始PHP(如今天)。 我想创建一个可定制的菜单使用jquery脚本,可以有一个可变数量的项目。PHP“动态”菜单
我收到一个错误,当我运行这个。 错误是:
Parse error: syntax error, unexpected T_VARIABLE in /home/s0urc3/public_html/files01/menu.php on line 5
由于Chase他的回答
的index.php:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<head>
<?PHP
$script_url="http://files01.s0urc3.ismywebsite.com/jquery/nagging-menu/nagging-menu.js";
$menu_css="http://files01.s0urc3.ismywebsite.com/jquery/nagging-menu/style.css";
$links = array(
array("url" => "http://www.something1.com", "label" => "something"),
array("url" => "http://www.something2.com", "label" => "something2"),
array("url" => "http://www.something3.com", "label" => "something3"),
);
include("menu.php");
?>
<meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1"/>
<title></title>
<link rel="shortcut icon" href="favicon.ico" type="image/x-icon"/>
<link rel="stylesheet" type="text/css" href=".css"/>
</head>
<body>
<?=writeMenu($links, $menu_css, $script_url)?>
</body>
</html>
menu.php:
<?
function writeMenu($links, $script_url, $menu_css){
$menu = '<link href=\"$menu_css\" type=\"text/css\">'
$menu = '<div id="navi">';
$menu .= '<div id="menu" class="default">';
$menu .= '<ul>';
foreach ($links as $item) {
$menu .= "<li><a href=\"".$item['url']."\">".$item['label']."</a></li>";
}
$menu .= "</ul>";
$menu .= "</div>";
$menu .= "<script type=\"text/javascript\" src=\"http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js\" charset=\"utf-8\"></script>";
$menu .= "<script type=\"text/javascript\" src=$script_url charset=\"utf-8\"></script>";
return $menu;
}
?>
感谢Chase为他的脚本
不要只说“谢谢Chase”,而是接受并赞扬他的回答 - 行动胜于言语,尤其是在具有在接受答案时奖励用户的功能的媒介。 – Jasper 2010-08-25 21:44:33
我会,但我还没有解决这个问题。 – ellisgeek 2010-09-01 20:02:30