1
0
Fork 0
php-coding/14.test3.php

47 lines
1.0 KiB
PHP

<?php
class Person
{
public string $name;
public float $height;
public float $weight;
public int $age;
public int $sex; // 0 female 1 male
/**
* @param string $name
* @param float $height
* @param float $weight
* @param int $age
* @param int $sex
*/
public function __construct(string $name, float $height, float $weight, int $age, int $sex)
{
$this->name = $name;
$this->height = $height;
$this->weight = $weight;
$this->age = $age;
$this->sex = $sex;
}
public function __destruct()
{
echo 'Person的析构方法被调用';
}
/**
* @return mixed
*/
public function bootFoolball(): mixed
{
if ($this->height < 185 && $this->weight < 85) {
return $this->name . '符合要求';
} else {
return $this->name . '不符合要求';
}
}
}
$person = new Person(name: '明日', height: 185, weight: 80, age: 20, sex: 1);
echo $person->bootFoolball();