Page 1 of 1

php Functions question

Posted: Wed Nov 03, 2010 2:05 pm
by LadyCherry
Hello there,

I actually had a php question.

What im trying to do is create a page that uses functions and switches on its own with a URL such as:
http://testerfake.com/functions.php?op=main
then one like this:
http://testerfake.com/functions.php?op=second

Those would take you to the same file but the function in them would make it look like a different page.

I guess the trouble im having is having a page do that on its own. (Seeing the op and the main or second in the URL respectively using switch and case)

Heres an example I have that is not working.

Code: Select all

<?php
/************************************************************************/
/*Functions Example                                                     */
/************************************************************************/
function mainpage()
        {
        echo \\\"Main Page\\\";
        }

function secondpage()
        {
        echo \\\"Second Page\\\";
        //This would make it go back to main page:
        //mainpage();
        }

switch($op)
        {
        case \\\"main\\\":
        mainpage();
        break;

        case \\\"second\\\":
        secondpage();
        break;

        }
?> 
What am I missing? A parse url or something?

Thank you very much for your help

Re: php Functions question

Posted: Wed Nov 03, 2010 2:13 pm
by mikosiko

Re: php Functions question

Posted: Thu Nov 04, 2010 8:33 am
by LadyCherry
Oh excellent!

Thank you thats exactly what i was looking for!