I'm new to PHP. I've done a few things already using PHP to query a MySQL database etc. However, I have to ask about webpages that use just one index.php file to load the various pages and sections onto. How do I do this in a single PHP file? Maybe I need to use functions in order to store the content for all the pages and then use the $_GET superglobal to call a function depending on whatever link the user clicks on? I could be completely wrong, and I really want to get used to doing this. Could someone please explain this to me and maybe post some code so that I can see how it should look? As I say, I'm kind of new to PHP, but I can more or less understand the principles of it. Thanks.
All Pages In A Single Index
ThomasT1991;10909918 wrote:I'm new to PHP. I've done a few things already using PHP to query a MySQL database etc. However, I have to ask about webpages that use just one index.php file to load the various pages and sections onto. How do I do this in a single PHP file? Maybe I need to use functions in order to store the content for all the pages and then use the $_GET superglobal to call a function depending on whatever link the user clicks on? I could be completely wrong, and I really want to get used to doing this. Could someone please explain this to me and maybe post some code so that I can see how it should look? As I say, I'm kind of new to PHP, but I can more or less understand the principles of it. Thanks.
that's how i do it
$page = (isset($_GET['page'])) ? mysql_real_espcae_string($_GET['page']): 'home';
//html header
switch($page) {
case 'home':
$this->home();
break;
//.. ect, function for each page
default:
$this->home();
break;
}
//html footer