Announcement

Collapse
No announcement yet.

Very basic question: args in URL

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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?

  • #2
    You need to read the argument:

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

    or

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

    Comment


    • #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


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

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

        Comment


        • #5
          Originally posted by webrunner View Post
          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


          • #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...
            X