dzimmo

Quest_PHP1_task8

Jun 14th, 2018
88
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2. //Создадим аасоциативный массив содержащий названия файлов
  3. //и названия пунктов меню за которые они отвечают:
  4. $pages = ["index.inc.php"=>"Главная","about.inc.php"=>"О компании","catalog.inc.php"=>"Каталог"];
  5. //Описываем функцию отвечающую за вывод меню:
  6. function menu($pagesArray) {
  7.     foreach ($pagesArray as $key => $value)
  8.         echo "<a class='nav-item nav-link' href='/quest-php1-application_task8/?page={$key}'>{$value}</a>";
  9. }
  10. //Описываем функцию отвечающую за подключение страниц. Если нет get запроса(при старте) то
  11. //выводит стартовую, если файла отвечающего за страницу нет, то выводит 404
  12. function including($pageName){
  13.     if(!empty($pageName)) $page = $pageName;
  14.     else                  $page = "index.inc.php";
  15.     $fileName = "pages/{$page}";
  16.     if (file_exists($fileName)) include $fileName;
  17.     else                        include "pages/page404.inc.php";
  18. }
  19. ?>
  20.  
  21. <!DOCTYPE html>
  22. <html lang="en">
  23. <head>
  24.     <meta charset="UTF-8">
  25.     <meta name="viewport" content="width=device-width, initial-scale=1.0">
  26.     <meta http-equiv="X-UA-Compatible" content="ie=edge">
  27.     <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.1/css/bootstrap.min.css" integrity="sha384-WskhaSGFgHYWDcbwN70/dfYBj47jz9qbsMId/iRN3ewGhXQFZCSftd1LZCfmhktB" crossorigin="anonymous">
  28.     <title>Document</title>
  29. </head>
  30. <body>
  31. <div class="container">
  32. <nav class="navbar navbar-dark bg-dark">
  33.   <a class="navbar-brand" href="#">
  34.     <img src="http://getbootstrap.com/docs/4.1/assets/brand/bootstrap-solid.svg" width="30" height="30" class="d-inline-block align-top" alt="">
  35.     Bootstrap
  36.   </a>
  37.   <?php menu($pages); ?>
  38. </nav>
  39. <div class="row">
  40.     <div class="col-12">
  41.         <?php including($_GET["page"]); ?>
  42.     </div>
  43. </div>
  44. </div>
  45.  
  46. <script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
  47. <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js" integrity="sha384-ZMP7rVo3mIykV+2+9J3UJ46jBk0WLaUAdn689aCwoqbBJiSnjAK/l8WvCWPIPm49" crossorigin="anonymous"></script>
  48. <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.1/js/bootstrap.min.js" integrity="sha384-smHYKdLADwkXOn1EmN1qk/HfnUcbVRZyYmZ4qpPea6sjB/pTJ0euyQp0Mk8ck+5T" crossorigin="anonymous"></script>
  49. </body>
  50. </html>
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×