Jump to content

Break; Return; help


xyn

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]
Link to comment
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]
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.