Very basic question: args in URL

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ircmullaney
    New Member
    • Aug 2008
    • 10

    Very basic question: args in URL

    I must have forgotten how arguments work because this isn't working for me. If this file is called:

    mysite.com/test.php

    And I use this in the browser:

    mysite.com/test.php?option=home

    PHP Code:
    <?php
    echo "<p>The option is \"$option\"</p>";
    ?>
    Shouldn't the output be:

    Code:
    The option is "home"
    Instead I'm just getting:

    Code:
    The option is ""
    Am I forgetting a step? Or could it be something about how my site is configured?
  • DoE
    Senior Member
    • Sep 2007
    • 763

    #2
    You need to read the argument:

    <?php
    echo $_REQUEST['option'];
    ?>

    or

    $option = $_REQUEST['option'];
    echo $option;

    Comment

    • Brandon_R
      Banned
      • Aug 2009
      • 243

      #3
      register_globals are deprecated so using your way is not advised. You can either use the globals array $GLOBALS['_GET']['option'], the request array $_REQUEST['option'] or the more specific get array $_GET['option'] for said problem.

      Comment

      • webrunner
        Member
        • Sep 2005
        • 63
        • 5.0.X

        #4
        does this work in php direct evaluation pages in the CMS?

        ( i can't seem to get it to work )

        Comment

        • lastnico
          New Member
          • Mar 2009
          • 19

          #5
          Originally posted by webrunner
          does this work in php direct evaluation pages in the CMS?

          ( i can't seem to get it to work )
          Yes, it works, but using the classical $_GET['option']. Even if it's an PHP evaluation, you have access to the whole PHP environment.
          Forum Software Reviews
          Review, compare and test forum software solutions.

          http://www.forum-software.org/review-bar/vbulletin4
          vBulletin score: 10/10!
          Vote for best forum software of 2011

          Comment

          • webrunner
            Member
            • Sep 2005
            • 63
            • 5.0.X

            #6
            Thanks, i got it working with that!

            Comment

            widgetinstance 262 (Related Topics) skipped due to lack of content & hide_module_if_empty option.
            Working...