, :
function display($name, $age, $job) {
echo $name . " is " . $age . " and is " . $job . ".<br />"
}
display("Obama", 50, "president of the United States");
display("Bill Gates", 60, "Founder of Microsoft");
display("Jacob", 20, "a student");
:
50 .
60 Microsoft
20
, .
class personInformation {
public $name;
public $age;
public $job;
public function __construct($name, $age, $job) {
$this->name = $name;
$this->age= $age;
$this->job= $job;
}
public function display() {
return $this->name . ' is ' . $this->age . ' and is ' . $this->job . '.<br />';
}
}
, , :
$obama = new personInformation("Obama", 50, "president of the United States");
$bill = new personInformation("Bill Gates", 60, "Founder of Microsoft");
$jacob = new personInformation("Jacob", 20, "a student");
echo $obama->display();
echo $bill->display();
echo $jacob->display();
__construct , , . :
$obama = new personInformation();
$obama->name = "obama";
$obama->age= 50;
$obama->job= "president of the United States";
__construct function , __construct , :
$obama = new personInformation("Obama", 50);
, :
public function hello() {
return $this->name . ' says hello. <br />';
}