php Functions question

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
LadyCherry
Forum Newbie
Posts: 2
Joined: Wed Nov 03, 2010 1:21 pm

php Functions question

Post 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
mikosiko
Forum Regular
Posts: 757
Joined: Wed Jan 13, 2010 7:22 pm

Re: php Functions question

Post by mikosiko »

LadyCherry
Forum Newbie
Posts: 2
Joined: Wed Nov 03, 2010 1:21 pm

Re: php Functions question

Post by LadyCherry »

Oh excellent!

Thank you thats exactly what i was looking for!
Post Reply