<?php
/**
* Created by PhpStorm.
*/
class people
{
private $name = '';
private $age = 0;
function __construct($n,$a)
{
$this->name = $n;
$this->age = $a;
}
function intro()
{
return "my name is {$this->name}, i am {$this->age} years old.<br>";
}
function get_name()
{
return $this->name;
}
function get_age()
{
return $this->age;
}
}
class student extends people
{
}
$stu = new student('wangfu',21);
if($stu instanceof student)
{
echo "stu is a student class.<br>";
}
if($stu instanceof people)
{
echo "stu is a people class.<br>";
}
PHP基础-类的继承使用01
猜你喜欢
转载自blog.csdn.net/modern358/article/details/89763139
今日推荐
周排行