Warning: Cannot use a scalar value as an array in /home/admin/public_html/forum/include/fm.class.php on line 757

Warning: Invalid argument supplied for foreach() in /home/admin/public_html/forum/include/fm.class.php on line 770
Форумы портала PHP.SU :: Версия для печати :: Переход по ссылке методом GET
Форумы портала PHP.SU » » Вопросы новичков » Переход по ссылке методом GET

Страниц (1): [1]
 

1. romantik2011 - 06 Сентября, 2011 - 18:26:34 - перейти к сообщению
Написал сам код, проблема в меню, получается переход на ссылку
http://test[dot]ru/index.php/index[dot]p[dot][dot][dot]dex.php?id=page1
вместо указанной мною в коде http://test[dot]ru/index.php/?id=page1

Подскажите, где не так? Архив вложил, вот его главный файл и файл меню.
index.php
CODE (text):
скопировать код в буфер обмена
  1.  
  2.  <?php include 'menu.php';?>
  3. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  4. <html xmlns="http://www.w3.org/1999/xhtml">
  5. <head>
  6. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  7. <title>Основы блочной верстки (Div верстки)</title>
  8. <link rel="stylesheet" type="text/css" href="/style.css" />
  9. </head>
  10. <body>
  11. <div id="wrapper">
  12. <div id="header"><span style="font-size:34px;">Сайт</span></div>
  13.  
  14. <div id="left">
  15. <h2 style="border-bottom:1px solid black;">Menu</h2>
  16. <? getMenu($menu);?>
  17. </div>
  18.  
  19.  
  20. <div id="right"><h2 style="border-bottom:1px solid black;">Menu</h2>
  21. <? getMenu($menu);?>
  22. </div>
  23. <div id="kontent">
  24. <?php
  25. $id = (isset($_GET['$id']))?$_GET['$id']:include 'home.php';
  26. switch($id){
  27. case 'page1': include 'page1.php'; break;
  28. case 'page2': include 'page2.php'; break;
  29. case 'page3': include 'page3.php'; break;
  30. }
  31. ?>
  32. </div>
  33. <div id="footer">Copyright © Филип Киркоров <? echo date('Y'); ?></div>
  34.  
  35. </div>
  36.  </body>
  37. </html>
  38.  


menu.php
CODE (text):
скопировать код в буфер обмена
  1.  
  2. <?php
  3. $menu = array(
  4.         'Page1' => 'index.php?id=page1',
  5.         'Page2' => 'index.php?id=page2',
  6.         'Page3' => 'index.php?id=page3'
  7. );
  8.  
  9.  
  10. function getMenu($masiv){
  11. echo '<ul>';
  12.         foreach($masiv as $href=>$value){
  13.                 echo "<li><a href=\"$value\">$href</a></li>";
  14.         }
  15. echo '</ul>';
  16. }
  17.  
  18. ?>
  19.  
2. GiD-Man - 06 Сентября, 2011 - 22:24:24 - перейти к сообщению
Добавь в начале адреса ссылки знак "/".
Должно получится "/index.php?id=page1".

 

Powered by ExBB FM 1.0 RC1