I am trying to display content depending on page id, however when I add nothing to the url, so just index.php I get an error saying that $p
is not defined, how can I give this var a default value that's outside the switch case?
<?php
$p = $_GET['p'];
switch ($p) {
case 1:
$content1 = new login();
$content = $content1->displayLogin();
break;
case 2:
echo "ID is 2";
break;
case 3:
echo "ID is 3";
break;
default:
$content1 = new dbconnection();
$content = $content1->displayTable();
}