First of all let me just say I have never used a class in PHP!
I was wondering how I would pass a class between pages? Is this possible? I'm creating an inventory module for an administration site, and I would like to create an Items class to hold such things as itemid, price, tax, etc. Just for testing purposes, I have created a couple pages to see if I can pass an object between them. I am having no luck. Please help if you can, it would be appreciated. Here is the method I have been trying. (It's just a skeleton right now, but if I can get this working then I can elaborate on it)
CLASS..
class InventoryItem {
var $memID;
var $memBasePrice;
function InventoryItem($ID) {
$this->memID = $ID;
}
function get_ID() {
return $this->memID;
}
function get_BasePrice() {
return $this->memBasePrice;
}
function set_BasePrice($BasePrice) {
$this->memBasePrice = $BasePrice;
}
}
//PAGE1..
$objItem = new InventoryItem(99);
echo "My item id is =".$objItem->get_ID(); //works fine
//these lines are straight html..
<form action="index.php?page=page2" method="post">
<input type="hidden" name="myclass" value="<?= $objItem?>">
<input type="submit" name="submit" value="Submit">
</form>
//PAGE2.. (doesn't work)
$myobj = $_REQUEST["myclass"];
echo "My passed item id is =".$myobj->get_ID();