Results 1 to 8 of 8
  1. #1

    REALLY basic PHP question about functions

    Hello
    If I enter the following URL:

    http://www.myserver.com/auction.php?searchterm=mac

    That means, the funciton "auction.php" will be executed, and pass the term"mac" as $searchterm

    Is that right?

  2. #2
    Join Date
    Jul 2002
    Posts
    148
    If register_globals are On, yes.

    If register_globals are Off, no:
    $searchterm = $HTTP_GET_VARS["searchterm"];

  3. #3
    Join Date
    May 2002
    Location
    UK
    Posts
    2,997
    If you are using PHP4.1.0 or newer you should try to always to program with the super global arrays

    $_GET['searchterm']

    as HTTP_GET_VARS is a deprecated method which means now that they have warned you they could remove it from the language whenever they felt like it.

  4. #4
    Thanks,
    If I'm running Mac OS X and Apache with PHP,
    how do I turn this feature "ON"

    Thanks!

  5. #5
    Originally posted by kenfused
    Thanks,
    If I'm running Mac OS X and Apache with PHP,
    how do I turn this feature "ON"

    Thanks!
    If you want to maintain the posibility of moving your script to other servers which you have no control over, I think you'll want to use the superglobals ($_GET, $_REQUEST, $_POST) for accessing the variables

    http://site.com/index.php?action=load

    The action variable will have to be accessed by using for example $_GET['action']

  6. #6
    optionally for the lazy and those not worried about their security the extract() function is readily available.

    PHP Code:
    extract($_REQUEST); 
    placing that at the top of your file with sort of work around register globals. though it's not recommended it will do what you want and leave your code working on servers with register_globals turned off.

  7. #7
    Thanks!

  8. #8
    Join Date
    Apr 2002
    Location
    Philly Pa
    Posts
    130
    function register_globals() {
    if (!ini_get('register_globals')) {
    $__am = array(&$_COOKIE, &$_POST, &$_GET);
    while (list(,$__m) = each($__am)) {
    if (is_array($__m)) {
    $GLOBALS += $__m;
    }
    }
    }
    }

Posting Permissions

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