473,416 Members | 1,838 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,416 software developers and data experts.

Accessing $HTTP_GET_VARS in classes..?

Hey guys,

I'm building a web application in php for the first time (I like php a
lot..) and have come across a litle stumbling block.

I want to access a passed url parameter with $HTTP_GET_VARS in a class, but
I can't get it to work.

Note the following php page, which creates an object that pulls the "param"
parameter in both the class and globally. The global one works, the one in
the class doesn't.

I'm sure I'm doing something stupid - any pointers..?

Thanks,

----------------------------------------------------------------------------
-
Call the page with "test.php?param=value"
----------------------------------------------------------------------------
-

<?php
class oTest
{
var $param;

function oTest()
{
$this -> param = $HTTP_GET_VARS["param"];
}
}
?>
<html>
<head>
</head>
<body>
<?php
$my_instance = new oTest;

print "From object: " . $my_instance->param . "<br>";
print "From global: " . $HTTP_GET_VARS["param"];
?>
</body>
</html>

--
Ben Hall
www.benhall.co.uk
Jul 16 '05 #1
2 3172
Ah, figured as soon as I asked for help, I'd fix it...

I needed to global $HTTP_GET_VARS... duh!!

Thanks anyway... :)

--
Ben Hall
www.benhall.co.uk
Jul 16 '05 #2
"Ben Hall" <be**@seriously-productions.freeserve.co.uk> schrieb:
I'm building a web application in php for the first time (I like php a
lot..) and have come across a litle stumbling block.

I want to access a passed url parameter with $HTTP_GET_VARS in a class, but
I can't get it to work.´


Try

global $HTTP_GET_VARS;

in the first line of the function. In the PHP documentation at
http://www.php.net/manual/en/languag...bles.scope.php you'll find
some more informations.

Matthias
Jul 16 '05 #3

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

Similar topics

5
by: Phrylock | last post by:
I am a beggining PHP developer (been doing it for like 3 weeks now) and I am currently having a problem getting these arrays to work. I am running PHP 4.3.4 with Apache 2.0.47 on WinXP. I have a...
2
by: John Pastrovick | last post by:
I am new to PHP, coming from ASP coding if (HTTP_GET_VARS==1){ print "Yes"; }else{ print "No"; } when "b" is not passed via (http://www.mydomain.com?b=1
4
by: Sims | last post by:
Hi, Is it wrong to forcefully set a value HTTP_GET_VARS and HTTP_POST_VARS $HTTP_GET_VARS = 'bar'? If yes, why? and how can i pass value between one page and the other without using the url?...
1
by: Jason | last post by:
this is my code and what i get... i'm accessing this through this url http://192.168.0.2/php/test2/test.php?user=me@test.ca&subject=test it grabs the correct stuff from the database, but...
1
by: Chris Cox | last post by:
Hi, Hoping someone can help, I have a sql query which is passed to the script via the url, this is like:- &stmt=select%20*%20from%20table%20where%20(%20status!='Closed'%20..... If I look at...
1
by: jimfollett1 via DotNetMonster.com | last post by:
Hey all, I was wondering if you could put me out of my misery (hopefully, not literaly) .. I am currently trying to port some VB6 code to VB.NET because of a possible significant performance...
5
by: Cyril Gupta | last post by:
Hello, I have a class inside another class. The Scenario is like Car->Engine, where Car is a class with a set of properties and methods and Engine is another class inside it with its own set of...
2
by: Jimmy Reds | last post by:
Hi, I have a blood glucose meter (a Lifescan OneTouch Ultra in case anyone was wondering) which I connect to my PC using a USB cable and I would like to have a go at accessing the data on this...
9
by: fgh.vbn.rty | last post by:
Say I have a base class B and four derived classes d1, d2, d3, d4. I have three functions fx, fy, fz such that: fx should only be called by d1, d2 fy should only be called by d2, d3 fz should...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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:
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
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

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.