Jump to content

How to make multiple pages through one file


jdock1

Recommended Posts

Im still a noob in PHP & got a rather stupid question.

 

Many sites running php use pretty much one php file for everything.

 

For example, a site uses index.php for everything. There are other pages defined as index.php?id=1 & index.php?id=2 etc.

 

Ive been trying code out and cant really do it all that well.

 

Could somebody explain this for me?

 

Thanks

The whole index.php?id= thing is using the GET method.

 

<?php
$id = $_GET['id'];

switch($id){
     case 1: include "page1.php"; break;
     case 2: include "page2.php"; break;
     default: include "home.php";
}
?>

uhh thats it thanks. I knew that, but I didnt know to use switch

Archived

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

×
×
  • 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.