473,396 Members | 1,766 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Query Strings, extract() and including pages

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.

Jul 17 '05 #1
5 2043
Logical wrote:
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');

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
Jul 17 '05 #2

"Logical" <me@privacy.net> wrote in message
news:41***********************@un-2park-reader-01.sydney.pipenetworks.com.au...
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.


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/
Jul 17 '05 #3
Pieter Nobels wrote:
Logical wrote:
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');


In your included file, you can use:

global $id, $foo;

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


Isn't global-ing variables like that not required?
<http://www.php.net/manual/en/language.variables.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).
Jul 17 '05 #4
Chung Leong wrote:
"Logical" <me@privacy.net> wrote in message
news:41***********************@un-2park-reader-01.sydney.pipenetworks.com.au...
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.

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

parse_str(), that's it!
Thanks.
Jul 17 '05 #5
"Logical" wrote:
Pieter Nobels wrote:
Logical wrote:
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’);


In your included file, you can use:

global $id, $foo;

And you’ll be able to use those variables just like any

other variable.

Isn’t global-ing variables like that not required?
<http://www.php.net/manual/en/language.variables.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).


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
Jul 17 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: theboss3 | last post by:
I am having trouble with accessing files with query strings. For example the code "require 'template.php?102932'" gives the following error: Warning: main(/www/blog/template.php?102932):...
20
by: Ravi | last post by:
Hi, I have about 200GB of data that I need to go through and extract the common first part of a line. Something like this. >>>a = "abcdefghijklmnopqrstuvwxyz" >>>b = "abcdefghijklmnopBHLHT"...
4
by: Venkat | last post by:
Hi All, I need to copy strings from a single dimensional array to a double dimensional array. Here is my program. #include <stdio.h> #include <stdlib.h>
6
by: Martin Lacoste | last post by:
Ok, before I headbutt the computer... don't know why when I add criteria in a query, I get an 'invalid procedure call'. I also don't know why after searching the help in access, the various access...
3
by: Serious_Practitioner | last post by:
Good day, and thank you in advance for any assistance you can provide. I have a table in an Access 2000 .mdb file, and I've run into something odd and insolvable, at least for me. The database is...
8
by: Bob | last post by:
I need to create a Regex to extract all strings (including quotations) from a C# or C++ source file. After being unsuccessful myself, I found this sample on the internet: ...
2
by: Jeff Gardner | last post by:
Greetings: I am attempting to split an input string using the str_word_count function to return multiple single word query variables. I can create an array based on...
2
by: Simon Rigby | last post by:
Hi folks, ASP.NET2, Sql Server 2005 I have an app that executed a sql server query that produces an XML file used as the DateFile for an XMLDataSource bound to a TreeView. The bizarre thing...
17
by: NeoAlchemy | last post by:
I am starting to find more web pages that are using a query parameters after the JavaScript file. Example can be found at www.opensourcefood.com. Within the source you'll see: <script...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.