|
构造方法
<style type="text/css">
<!--
body,td,th {
font-size: 12px;
}
body {
margin-left: 10px;
margin-top: 10px;
margin-right: 10px;
margin-bottom: 10px;
}
-->
</style>
<?php
class MyObject{
public $object_name;
public $object_price;
public $object_num;
public $object_agio;
function __construct($name,$price,$num,$agio){
$this -> object_name = $name;
$this -> object_price = $price;
$this -> object_num = $num;
$this -> object_agio = $agio;
}
function setObjectName($name){
$this -> objecct_name = $name;
}
function getObjectName(){
return $this -> object_name;
}
}
$c_book = new MyObject('Western-style clothes',1500,5,8);
echo $c_book -> getObjectName();
?>
执行结果:
Western-style clothes
|
|