Query Strings, extract() and including pages

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Logical

    Query Strings, extract() and including pages

    I wanted to do:
    include('page.h tm?id=12&foo=ba r');

    But since I can't (and don't want to make another seperate HTTP request
    with include('http://...')); I was wondering if there's a function
    similar to extract(); that can handle a query string as input, so that I
    could:
    $id = 12;
    $foo = 'bar';
    include('page.h tm');

    I am using this on a 'processor' style page to interperet URLs as
    http://foo.com/bla. It consults a database to manage a large number of
    URLs to their pages.

  • Pieter Nobels

    #2
    Re: Query Strings, extract() and including pages

    Logical wrote:[color=blue]
    > I wanted to do:
    > include('page.h tm?id=12&foo=ba r');
    >
    > But since I can't (and don't want to make another seperate HTTP request
    > with include('http://...')); I was wondering if there's a function
    > similar to extract(); that can handle a query string as input, so that I
    > could:
    > $id = 12;
    > $foo = 'bar';
    > include('page.h tm');[/color]
    In your included file, you can use:

    global $id, $foo;

    And you'll be able to use those variables just like any other variable.

    --
    Pieter Nobels

    Comment

    • Chung Leong

      #3
      Re: Query Strings, extract() and including pages


      "Logical" <me@privacy.net > wrote in message
      news:4119f186$0 $31716$61c65585 @un-2park-reader-01.sydney.pipen etworks.com.au. ..[color=blue]
      > I wanted to do:
      > include('page.h tm?id=12&foo=ba r');
      >
      > But since I can't (and don't want to make another seperate HTTP request
      > with include('http://...')); I was wondering if there's a function
      > similar to extract(); that can handle a query string as input, so that I
      > could:
      > $id = 12;
      > $foo = 'bar';
      > include('page.h tm');
      >
      > I am using this on a 'processor' style page to interperet URLs as
      > http://foo.com/bla. It consults a database to manage a large number of
      > URLs to their pages.
      >[/color]

      Don't quite understand what you're trying to do, but I think parse_str() is
      what you're looking for.


      --
      Obey the Clown - http://www.conradish.net/bobo/


      Comment

      • Logical

        #4
        Re: Query Strings, extract() and including pages

        Pieter Nobels wrote:[color=blue]
        > Logical wrote:
        >[color=green]
        >> I wanted to do:
        >> include('page.h tm?id=12&foo=ba r');
        >>
        >> But since I can't (and don't want to make another seperate HTTP
        >> request with include('http://...')); I was wondering if there's a
        >> function similar to extract(); that can handle a query string as
        >> input, so that I could:
        >> $id = 12;
        >> $foo = 'bar';
        >> include('page.h tm');[/color]
        >
        > In your included file, you can use:
        >
        > global $id, $foo;
        >
        > And you'll be able to use those variables just like any other variable.[/color]

        Isn't global-ing variables like that not required?
        <http://www.php.net/manual/en/language.variab les.scope.php>

        I'm actually more concerned about how to get $id and $foo 'out of' the
        query string attached to the URL (this part: page.htm?id=12& foo=bar).

        Comment

        • Logical

          #5
          Re: Query Strings, extract() and including pages

          Chung Leong wrote:
          [color=blue]
          > "Logical" <me@privacy.net > wrote in message
          > news:4119f186$0 $31716$61c65585 @un-2park-reader-01.sydney.pipen etworks.com.au. ..
          >[color=green]
          >>I wanted to do:
          >>include('page .htm?id=12&foo= bar');
          >>
          >>But since I can't (and don't want to make another seperate HTTP request
          >>with include('http://...')); I was wondering if there's a function
          >>similar to extract(); that can handle a query string as input, so that I
          >>could:
          >>$id = 12;
          >>$foo = 'bar';
          >>include('page .htm');
          >>
          >>I am using this on a 'processor' style page to interperet URLs as
          >>http://foo.com/bla. It consults a database to manage a large number of
          >>URLs to their pages.
          >>[/color]
          >
          >
          > Don't quite understand what you're trying to do, but I think parse_str() is
          > what you're looking for.
          >
          >[/color]
          parse_str(), that's it!
          Thanks.

          Comment

          • steve

            #6
            Re: Re: Query Strings, extract() and including pages

            "Logical" wrote:[color=blue]
            > Pieter Nobels wrote:[color=green]
            > > Logical wrote:
            > >[color=darkred]
            > >> I wanted to do:
            > >> include(’page.h tm?id=12&foo=ba r’);
            > >>
            > >> But since I can’t (and don’t want to make another[/color][/color]
            > seperate HTTP[color=green][color=darkred]
            > >> request with include(’http://...’)); I was[/color][/color]
            > wondering if there’s a[color=green][color=darkred]
            > >> function similar to extract(); that can handle a query string[/color][/color]
            > as[color=green][color=darkred]
            > >> input, so that I could:
            > >> $id = 12;
            > >> $foo = ’bar’;
            > >> include(’page.h tm’);[/color]
            > >
            > > In your included file, you can use:
            > >
            > > global $id, $foo;
            > >
            > > And you’ll be able to use those variables just like any[/color]
            > other variable.
            >
            > Isn’t global-ing variables like that not required?
            > <http://www.php.net/manual/en/language.variab les.scope.php>
            >
            > I’m actually more concerned about how to get $id and $foo
            > ’out of’ the
            > query string attached to the URL (this part:
            > page.htm?id=12& foo=bar).[/color]

            When you include a file, it inherits the scope of variables at the
            point of inclusion. It means that $id and $foo are available to the
            included script already. You would need to declare them as global
            only if your include is a function.

            steve

            --
            http://www.dbForumz.com/ This article was posted by author's request
            Articles individually checked for conformance to usenet standards
            Topic URL: http://www.dbForumz.com/PHP-Query-St...ict138606.html
            Visit Topic URL to contact author (reg. req'd). Report abuse: http://www.dbForumz.com/eform.php?p=466974

            Comment

            Working...