there was such a question: there is a site with a menu (when you click on the menu buttons, a new page of the site opens with certain information). In this version of the site, I pass the button press using the get function in a single php file and, depending on the value of the variable, draw this or that page. The value of the variable is checked in the same file. The question is, is it advisable to split the code of a single php file into several html files?

PS Below is part of the code of my php file. I ask a question in order to optimize the site as much as possible

<div class="roud"> <input type="button" class="r1" value="Главная" onclick=" location.href='my.php'"> <input type="button" class="r1" value="Услуги" onclick=" location.href='my.php?x=Услуги'"> <input type="button" class="r1" value="Техническое задание" onclick=" location.href='my.php?x=Техническое задание'"> <input type="button" class="r1" value="Контакты" onclick=" location.href='my.php?x=Контакты'"> <input type="button" class="r1" value="О нас" onclick=" location.href='my.php?x=О нас'"> <input type="image" class="r01" data-toggle="modal" data-target="#myModal" src="../images/viber1.png"> <input type="image" class="r01" data-toggle="modal" data-target="#myModal1" src="../images/WhatsApp1.png"> <input type="image" class="r01" data-toggle="modal" data-target="#myModal2" src="../images/telegram1.png"> </div> <?php if (isset($_GET["x"])) { $retur=$_GET["x"]; if ($retur=="Услуги"){ echo " ... "; } else { if ($retur=="Техническое задание"){ echo " ... "; } else { if ($retur=="Контакты"){ echo " ... "; } else { if ($retur=="О нас"){ echo " ... "; } } } } } else { echo " ... "; } 
  • one
    I understand you need php routing, actually read about it - Dantessss

1 answer 1

I also wanted to offer PHP Routing, but @Dantessss was a bit ahead of me. I studied it myself with the help of this article: http://maxsite.org/page/routing

I also recommend reading about the work of the Apache server and its .htaccess file. This file is very clearly explained in this article on Habré: https://habr.com/post/154643/