I have this PHP case statement
switch ($parts[count($parts) - 1]) {
case 'restaurant_pos':
include($_SERVER['DOCUMENT_ROOT'] . '/pages/restaurant_pos.php');
break;
case 'retail_pos':
include($_SERVER['DOCUMENT_ROOT'] . '/pages/retail_pos.php');
break;
.....
}
Which works great but I have many many files (like 190) and I would love to know if there is a way to make this case statement many work with anything so I dont have to do 190 case conditions. I was thinking I can use the condtion in the case and maybe see if that file is present and if so then display and if not then maybe a 404 page but i was not sure a good way to do this…any ideas would help alot
If it’s not user input, you can do it like
repeating, don’t do this if $include is being filled from user’s input !