mikes02 wrote:Thank you, I am still trying to get the hang of when the best situations are for using a switch.
Considering your use of the alternative syntax for control structures and "display this text", you are probably using PHP as a template language in this context. The disadvantage of using a switch here is that it may make it more difficult to track what is being compared, since "display this text" may be quite substantial.
If not for this consideration, a switch could be better as it typically makes it easier to understand what is being compared, e.g.,
$basename = basename(parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH));
switch ($basename)
{
case 'index.php':
// ...
break;
case 'page1.php':
// ...
break;
case 'page2.php':
// ...
break;
}