Posted by Marcin Dobrucki on 11/08/06 15:29
Marcel wrote:
> I have a person class adn i want to derive an object of that class on one
> page and pass that object to a next page but that does not work for me and i
> do not understand why.
....
I tried this code, and it works just fine. You didn't include the rest
of the code, so maybe there is something there that breaks it?
<?php
class A {
var $name;
function A($name) {
$this->name = $name; }
function getName() {
return $this->name; }
}
$a = new A("my name");
$a_serialized = urlencode(serialize($a));
header("Location: obj2.php?data=".$a_serialized);
?>
and:
<?php
class A {
var $name;
function A($name) {
$this->name = $name; }
function getName() {
return $this->name; }
}
$a = unserialize(urldecode($_GET['data']));
echo get_class($a);
echo "<br>";
echo $a->getName();
?>
[Back to original message]
|