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