I am trying to break into the PHP pool and I am facing a problem - I am trying to set up a way that I can simply add a new record to the array and this will make a new page so that someone can access.
This is the code:
switch ($page) {
foreach ($LINKS as $linkName => $linkAdd) {
case $linkName:
require "templates/views/$linkAdd";
}
default:
echo '404 Not Found';
break;
}
The loop gives me an error saying that it was unexpected to use the loop foreachinside switch, I was wondering if there was a way around this or if it just cheated not to use this method?
Is this just the loop foreachthat is executed by this method? Or there are other types of loops for this.
source
share