All code in 1 page or divide it to more pages?

I have a social network site with a page user profile. This page has tabs About me, My friends, My information, References.

Is it better for performance to get section via $_GET or to create for each section a new page?
so a)
profile.php

<?
if($_GET[section]=="aboutme"){
//display About me sectino
}elseif($_GET[section]=="myfriends"){
//display friends section
}elseif($_GET[section]=="references"){
//display references section
}elseif($_GET[section]=="myinformation"){
//display my information section
}
?>

b)
To create aboutme.php, myfriends.php, references.php, myinformation.php
c)
Same as a), but instead putting all code inside profile.php include for each section file.

<?
if($_GET[section]=="aboutme"){
//include_once('aboutme.php');
}elseif($_GET[section]=="myfriends"){
//include_once('friends.php');
...
?>

What is the best way of doing it?

Thank you

Pages that don’t share anything in common should be kept separate. It’s usually easier to maintain code that way.

Think about doing it the other way around - use a common header file for all of the other pages. Easier to maintain common code that way.

i think even if you start into single page ,you will later move onto separate page approach yourself,feeling the heat and complexcity as application grows :smiley:

so i recommend separate pages with common layout method…

Or, have your cake and eat it.

<?

if($_GET['section']=="aboutme"){

include 'aboutme.php' ;

}

Maybe are you worried about mulitple urls for users?

/index.php?section=aboutme
(with mod_rewrite this could be /aboutme )
vs
/aboutme.php

Or even:

<?

include 'pages.inc.php' ;

if($_GET['section']=="aboutme"){

aboutme();

}

With your first approach you’re heading towards an unmaintainable mess of code in a single file :eek: - this is not the way to go.

With the second approach you’re delaying the same inevitable problem as the first.

With the third approach, separate files for each distinct page with two (or more) levels of controllers to pick the correct page you’ve got room to grow and the added benefit of a lot more flexibility & re-use.

Attached: directory layout of the small-ish source tree I’m currently working on.

in addition to all above this is age of MVC…
where even single file single is divided into 3 or more files :slight_smile:
so when we consider all those initial methods seems like an ice age :smiley:
just kidding…but time is proving it as truth