x_maras Posted March 10, 2009 Share Posted March 10, 2009 i m trying to do a little project with a vending machine. <?php //error_reporting(0); include("machine1.php"); session_start(); $machine = new Machine1(); $machine->createForm(); $drink=$machine->createDrink($_POST['press']); echo "<br /> <br />"; echo $drink->getName(); echo "<br /> <br />"; echo "<form action='' method='post'> <input type='text' name='money' align='left' style='width:40' value='' /> <input type='submit' style='width:60' value='order'> </form> <br />"; $machine->order($_POST['money'],$drink); $money=$drink->getPrice(); echo $drink->getName(); echo $money; echo " </body> </html>"; ?> here is the code of the page. my problem is that i can't use the object $drink after the second submit in the order() How i could do an object to last? Quote Link to comment https://forums.phpfreaks.com/topic/148755-life-of-an-object/ Share on other sites More sharing options...
Mark Baker Posted March 10, 2009 Share Posted March 10, 2009 sessions Quote Link to comment https://forums.phpfreaks.com/topic/148755-life-of-an-object/#findComment-781066 Share on other sites More sharing options...
x_maras Posted March 10, 2009 Author Share Posted March 10, 2009 I know how to use session for a variable but for an object? Quote Link to comment https://forums.phpfreaks.com/topic/148755-life-of-an-object/#findComment-781075 Share on other sites More sharing options...
JonnoTheDev Posted March 10, 2009 Share Posted March 10, 2009 Objects can be stored in sessions also $_SESSION['drink']->getName(); Quote Link to comment https://forums.phpfreaks.com/topic/148755-life-of-an-object/#findComment-781078 Share on other sites More sharing options...
x_maras Posted March 11, 2009 Author Share Posted March 11, 2009 ok thanks i found it! Quote Link to comment https://forums.phpfreaks.com/topic/148755-life-of-an-object/#findComment-781999 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.