Jump to content

Life of an object


x_maras

Recommended Posts

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?

Link to comment
https://forums.phpfreaks.com/topic/148755-life-of-an-object/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.