Jump to content


Photo

Break; Return; help


  • Please log in to reply
2 replies to this topic

#1 xyn

xyn
  • Members
  • PipPipPip
  • Advanced Member
  • 779 posts
  • LocationNorthampton

Posted 08 August 2006 - 02:37 PM

Hey,
I have got my navigator on $_GET the problem with this is when
i call the exit; i lose everything else on the page below it. usually
my copyright.

I tried the following and it didn't work.
<?PHP
$pg = $_GET['page'];

if( !$pg ){
   include("index.php");
   break;

   } elseif( $pg == news ) {
   include("news.php");
   break;

   }
   else
   {
   echo ' no such page';
   break;
   }
   return;
?>


#2 wildteen88

wildteen88
  • Staff Alumni
  • Advanced Member
  • 10,482 posts
  • LocationUK, Bournemouth

Posted 08 August 2006 - 02:39 PM

Remove the break; and the return; they are not needed. if you are using an if/elseif/else statment. However it'll be better if you use a switch:
$pg = isset($_GET['page']) ? $_GET['page'] : 'home';

switch($pg)
{
    case 'home':
        include 'index.php';
    break;

    case 'news':
        include 'news.php';
    break;

    case default:
        echo "no such page";
    break;
}


#3 xyn

xyn
  • Members
  • PipPipPip
  • Advanced Member
  • 779 posts
  • LocationNorthampton

Posted 08 August 2006 - 03:46 PM

cheers :]




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users