Answer the question
In order to leave comments, you need to log in
How are separate pages of the site created (in addition to the main one)?
Couldn't google anything on this topic. Interested in creating separate pages of the site in addition to the main main page.
For example, there is a main page with a menu, and when you navigate through the menu, other pages open: about us, catalog, etc.
I read a long time ago that no one writes HTML and CSS code for the header, footer, etc. for these pages, but inserts them into a new page using PHP. Still interested in the dynamic creation of pages like on forums, etc. I would like to read more about this. Any links to relevant information are welcome.
Answer the question
In order to leave comments, you need to log in
Here is a very simple example for you.
++ static
+++ images
++++ logo.png
+ header.php
+ content.php
+ footer.php
<?php $logo_url = '/images/logo.png'; ?>
<header>
<h2>Тут хэдер</h2>
<p>А вот и лого:</p>
<img src="<?=$logo_url;?>" alt="logo">
</header>
<?php
require 'header.php';
$page = !empty($_GET['page'])
? filter_input(INPUT_GET, 'page', FILTER_SANITIZE_STRING)
: 'index' ; ?>
<main>
<?php if($page === 'index'): ?>
<p>Главная страница сайта.</p>
<?php else: ?>
<p>Не главная страница сайта.</p>
<a href="/">Перейти на главную</a>
<?php endif; ?>
</main>
<?php require 'footer.php'; ?>
<?php $copyright = 'Mr. Y'; ?>
<footer>
<h4>Тут футер</h4>
<p><?=$copyright;?></p>
</footer>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question