#1
  1. Banned (not really)
    Devshed Supreme Being (6500+ posts)

    Join Date
    Dec 1999
    Location
    Brussels, Belgium
    Posts
    14,642
    Rep Power
    4492
    Is it possible to send an object created in one php page to another.

    I'm creating a object called products that has a bunch of different variables within it (description, price, weight,etc...). I then use functions within the class to print out specific information to the page i.e. a short printout for lists of products, then a long printout when a viewer wants to see more details about the project, etc...

    If I create a new object with
    $item = new product;
    is there anyway to send $item to another php page and still be able to get at information such as
    $item->price;
    $item->weight;
    etc...

    Any help is appreciated. I hope I'm not overlooking something simple.

    ---John Holmes
    ---www.SepodatiCreations.com
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2000
    Posts
    38
    Rep Power
    15
    can you not just pass it as a variable would be passed?
    ex. http://foo.com/index.php3?object=$object

    im not sure on that though
  4. #3
  5. Banned (not really)
    Devshed Supreme Being (6500+ posts)

    Join Date
    Dec 1999
    Location
    Brussels, Belgium
    Posts
    14,642
    Rep Power
    4492
    I created an object called $buffalo and assigned some variables within it. Then I tried to pass it as
    <a href="test2.php?buffalo=<?php echo $buffalo; ?>">click here</a>

    When I held my mouse over the link it said it would open page:
    test2.php?buffalo=Object

    But when the second page opens, it says $buffalo isn't an object in that page.

    I even added the class definetion to test2.php3, but that didn't help.

    Thanks for the suggestion, though. If anyone else has any ideas, please let me know...

    ---John Holmes
    ---www.SepodatiCreations.com
  6. #4
  7. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2000
    Posts
    2
    Rep Power
    0
    have you tried sessions?
    rtfm php4 documentation about sessions or
    phplib docs (if you are using php3)

    ------------------

    Belu Bogdan - cobra@ines.ro
    webmaster
    INES Internet
  8. #5
  9. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2000
    Posts
    1
    Rep Power
    0
    This has to be the same mechanism like in session tracking with phplib or PHP4. You can set the product object in the $GLOBALS array, then retrieve it on the next page, but you must associate it with the current session/user.
    Regards,
    Atanas
  10. #6
  11. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2000
    Posts
    43
    Rep Power
    15
    's far as I know you can't pass objecs. Perhaps some kind of flattening mechanism (a la Perl). Remember the memory alloc'd for the obj dies with the script! You are only going to pass text (basically) into a script. With sessions, who knows? Try and let us know!

    ------------------
    PHP, Perl, SQL Programming at http://www.mentalobjects.com
  12. #7
  13. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2000
    Posts
    1
    Rep Power
    0
    I believe you can use the serialize() function before sending the object then unserialize() on the page receiving it. Check out serialize() in the PHP manual. Here is a link to it -http://www.php.net/manual/function.serialize.php3 - Make sure and check out the posts on the bottom of the page for helpful tips.

Similar Threads

  1. Post a mysql object from a form to a new page
    By NCAnnie in forum PHP Development
    Replies: 4
    Last Post: February 12th, 2004, 07:12 AM
  2. Replies: 0
    Last Post: February 8th, 2004, 10:11 PM
  3. sending percent signs to another page
    By aliaga61 in forum ASP Programming
    Replies: 1
    Last Post: February 5th, 2004, 08:38 AM
  4. view a DOM tree of any object on your page
    By tgrundy in forum HTML Programming
    Replies: 5
    Last Post: January 26th, 2004, 06:54 PM
  5. passing the url from HTML page to a php
    By lordorkus in forum PHP Development
    Replies: 10
    Last Post: January 20th, 2004, 05:36 PM

IMN logo majestic logo threadwatch logo seochat tools logo