Php index page utitlizing an idea for a superswitch...

Posted by Matt on Stack Overflow See other posts from Stack Overflow or by Matt
Published on 2010-05-27T12:09:00Z Indexed on 2010/05/27 12:11 UTC
Read the original article Hit count: 275

Filed under:

I dont know if this is a great idea...or a crap one. But I was thinking I may use one page to display all my pages using includes. Here is what my index.php would look like...on the functions include there is a function called "superSwitch" which will determine what requested page will be included....for instance

if I do a get ?a=a

it will goto the function superSwitch(a) superSwitch will take it and associate it with (login.php) then respond with such...

here is the code for the index.php...please let me know if this makes sense and might work, or should I just stick to long blocks of code (which is why I am trying this because I hate long pages full of code...)

of course as you can tell it is not actually including anything yet...the print is for debugging purposes. :)

Thanks, Matt

<?php
//includes Functions
include_once('inc/func.inc.php');
//set superget variable
$superget = @$_GET['a'];
//check if superget is set or null
if (!$superget) 
{
    echo "Nothing Requested :)";
}
else
{
    //sanitizes the superget request
    $supergetr = supergetSanitize($superget)
    //uses the result "good" or "nogood" to determine what happens
    if ( $supergetr == "good" ) {
        //pulls superSwitch value of the request
        $ssresult = superSwitch($superget);
        print_r ($ssresult);
    }
    //if the sanitize is nogood
    else
    {
        //the superSwitch is instructed to respond with a 404 page
        $superget = "404"
        $ssresult = superSwitch($superget);
        print_r ($ssresult);
    }
}
?>

© Stack Overflow or respective owner

Related posts about php