have you ever wondered what is this question mark following the index.php for?
domain.org/index.php?go=stuff
this string is called a dynamic inclusion. you always see that in every old website you visit...or at least you used to visit.
with that you can sort out all your php files in the index one, not just linking a single php file!
first you wanna create a hello world page, open up notepad or something like that. from here you will see a blank page. type in the following:
hello world!
and save as hello.php. this will be the placeholder main page.
next go to file > new (ctrl+n) and type:
here i am!
save the file as here.php with these two placeholder pages we will now create a dynamic inclusion!
create a new file and paste the code below. were not using the one from dodos new world bc its for older versions of php.
<?php
ㅤ$test = $_GET['test'];
ㅤif (!empty ($test)) {
ㅤㅤ$test .='.php'
ㅤㅤinclude($test);
ㅤ}
ㅤelse {
ㅤㅤinclude('hello.php');
ㅤ}
?>
note that ['test'] is the parameter by which the question mark is followed!
you can simply change test to your own parameter and variable as well as hello.php to your main php file.
save the file as test_d.php. your result would be ?test=here as it will display here i am!
in order to make things complex and secure especially for multiple pages you can also use the code below. add how much pages, array strings and variables youd like!
<?php
ㅤ$p = $_GET['page'];
ㅤ$page = array('1', '2', '3');
ㅤif (!empty($p)) {
ㅤㅤif(in_array($p,$page)) {
ㅤㅤㅤ$p .= '.php';
ㅤㅤㅤinclude($p);
ㅤㅤ}
ㅤㅤelse {
ㅤㅤecho 'uh oh! this page DOES NOT EXIST!!!';
ㅤㅤ}
ㅤ}
ㅤelse {
ㅤㅤinclude('main.php');
ㅤ}
?>