Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6

Thread: DO keyword

  1. #1
    Regular Coder ajetrumpet's Avatar
    Join Date
    Jul 2009
    Location
    Iowa City, IA
    Posts
    407
    Thanks
    44
    Thanked 5 Times in 5 Posts

    DO keyword

    can someone tell me what the DO keyword does in query strings? for example:
    PHP Code:
    search.php?do=process 
    is that a different type of query than those querying info from a database?

    thanks

  • #2
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,994
    Thanks
    4
    Thanked 2,662 Times in 2,631 Posts
    A querystring is a string, nothing more.
    The GET is split into key/value pairs from x=y within a querystring. The only thing that do represents is that $_GET['do'] will equate to 'process', but nothing more. What is done with it is up to the developer.

    In other words, 'do' within a query string does nothing.
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 
    Been gone for a few months, and haven't programmed in that long of a time. Meh, I'll wing it ;)

  • #3
    Regular Coder ajetrumpet's Avatar
    Join Date
    Jul 2009
    Location
    Iowa City, IA
    Posts
    407
    Thanks
    44
    Thanked 5 Times in 5 Posts
    Quote Originally Posted by Fou-Lu View Post
    A querystring is a string, nothing more.
    The GET is split into key/value pairs from x=y within a querystring. The only thing that do represents is that $_GET['do'] will equate to 'process', but nothing more. What is done with it is up to the developer.

    In other words, 'do' within a query string does nothing.
    I thought it had some special meaning. almost like a function. It is widely used then as a variable, is that right?

    what makes it so popular?

  • #4
    Super Moderator Inigoesdr's Avatar
    Join Date
    Mar 2007
    Location
    Florida, USA
    Posts
    3,647
    Thanks
    2
    Thanked 406 Times in 398 Posts
    Quote Originally Posted by ajetrumpet View Post
    what makes it so popular?
    It's just personal preference. It's generally easier to explain to someone who is fairly new to coding how the process works if you can say "do=action". It's more like natural language, and therefore easier to pick up.

  • #5
    Regular Coder ajetrumpet's Avatar
    Join Date
    Jul 2009
    Location
    Iowa City, IA
    Posts
    407
    Thanks
    44
    Thanked 5 Times in 5 Posts
    Quote Originally Posted by Inigoesdr View Post
    It's just personal preference. It's generally easier to explain to someone who is fairly new to coding how the process works if you can say "do=action". It's more like natural language, and therefore easier to pick up.
    can you give me a working example of "do=action"???

  • #6
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,994
    Thanks
    4
    Thanked 2,662 Times in 2,631 Posts
    PHP Code:

    function action()
    {
        print 
    'action!';
    }

    switch (@
    $_GET['do'])
    {
        case 
    'action':
            
    action(); // or even just process, which I don't like to do in switches myself as it becomes harder to read with more complicated instructions
            
    break;

    The naming is irrelevant. You could call it myawesomevariable=process if you wanted to.
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 
    Been gone for a few months, and haven't programmed in that long of a time. Meh, I'll wing it ;)


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •