Passing objects form one page to another

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Marcel

    #1

    Passing objects form one page to another

    Hello all,

    Is it possible to transfer objects derived from a class form one page to
    another?

    I made 2 testscripts:

    person.php
    -------------------------------------
    <?php

    class person {

    private $_name;

    public function setName($name) {

    $this->_name = $name;

    }

    public function getName() {

    return $this->_name;

    }

    }


    $p = new person();

    $p->setName("Jim") ;

    $safep = urlencode(seria lize($p));

    header("Locatio n:person2.php?d ata=".$safep);

    exit;

    ?>


    person2.php
    ---------------------------------
    <?php

    class person {

    private $_name;

    public function setName($name) {

    $this->_name = $name;

    }

    public function getName() {

    return $this->_name;

    }

    }

    $x = unserialize(url decode($_GET['data']));

    echo $x->getName();

    ?>

    But this does not work for me....

    Marcel


  • Binny V A

    #2
    Re: Passing objects form one page to another

    Hello Marcel,
    Is it possible to transfer objects derived from a class form one page to
    another?
    Have you tried passing it using session?

    --
    Binny V A
    Bin-Co is a site that provides some free and great codes for some of the programming languages. These include Open Sources for JavaScript, Perl, Tcl/Tk and others.

    Comment

    Working...