示例#1
0
            $ro = "rooms: {$this->rooms} ";
        }
        return $ro;
    }
}
?>
    <form action="" method="post">
      <p>address <input name="address"></p>
      <p>rooms <input name="rooms"></p>
      <p>windows <input name="windows"></p>
      <p>size <input name="size"></p>
      <p>price <input name="price"></p>
      <input  type="submit" name="send">
    </form>

    <?php 
if (isset($_POST['send'])) {
    $house = new insert_house();
    $house->address = $_POST['address'];
    $house->rooms = $_POST['rooms'];
    $house->windows = $_POST['windows'];
    $house->size = $_POST['size'];
    $house->price = $_POST['price'];
    echo $house->test();
    echo "<br>";
    echo $house->rooms();
}
?>
  </body>
</html>
示例#2
0
  <body>
    <?php 
class insert_house
{
    public $address;
    private $rooms;
    protected $windows;
    var $size;
    var $price = 100000;
    function test()
    {
        $re = $this->address . "<br>";
        $re .= $this->rooms . "<br>";
        $re .= $this->windows . "<br>";
        return $re;
    }
}
//end of the class insert_house
$insert_house = new insert_house();
$insert_house->address = 2;
// $insert_house->rooms = 3;
// $insert_house->windows = 2;
echo $insert_house->test();
?>

    

  </body>
</html>