Jump to content

Archived

This topic is now archived and is closed to further replies.

xyn

Break; Return; help

Recommended Posts

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.
[code=php:0]<?PHP
$pg = $_GET['page'];

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

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

  }
  else
  {
  echo ' no such page';
  break;
  }
  return;
?>[/code]

Share this post


Link to post
Share on other sites
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:
[code=php:0]$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;
}[/code]

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.