PHP Code to Include Content in Layout
<?php if($_GET['page'] == null) { include “default.php”; } else { include $_GET['page']; } ?>
The explaination of this is:
$_GET['page']
is the PHP way to get a parameter from a url. In PHP all the page parameters are stored after the ? in the url. For example in this page index.php?page=anything.php the only variable is page and in this case page is equal to “anything.php”. The $_GET['page'] gets the value of page. If you wish to add more variables to the url you simply add an & in between the variables. For example “index.php?page=anything.php&loggedin=false” Thus $_GET['loggedin'] would result in false. Next time you do a go0ogle search check the url and you can see these variables.
include “default.php”
The first include will be shown if the page variable is null. In this case it will show the default page you assign it.
include $_GET['page']
This will show the page of whatever follows the page variable in the url.
For an example of this visit my homepage http://rkania.com/index.php?view=home. My site has customized code and mod rewrite so it won’t work exactly the same.