In one of the comments on this question I learned that it is technically wrong to do a separate php file for each page in excess of index.php . Then the question is: how can we make it so that when switching to another page, the previous content is deleted and the new one appears if we are in the same index.php ?
Yes, I understand, for this purpose, special classes are written for routing, but I want to start with something simple, that I understand how it works, and then complicate it. Therefore, in this question, I ask you to show this example: when you click on the “Other page” menu item, we should stay at index.php , but the “This is the main” message should disappear, and something else should appear instead - it will be a transition imitation to another page using the navigation menu. Naturally, I ask you to do this in pure PHP without JavaScript .
<ul> <li><a href="#">Главная</a></li> <!-- неверно --> <!-- <li><a href="/other_page.php">Другая страница</a></li> --> </ul> <div> Это главная </div>