<?PHP
header("content-type:text/html; charset=utf-8");
//echo ucfirst('a b');

class Student{
 private $xh;
 private $name;
 
 function __construct($id,$name){
  $this->id = $id;
  $this->name = $name;
 }
 
 function hello(){
  echo '我的学号是:'.$this->id.'我的名字是:'.$this->name;
 }
}

$className = 'Student';
$stu = new $className('123456','谭斌');
$stu->hello();
?>

 

页面打印结果如下:

我的学号是:123456我的名字是:谭斌

相关文章:

  • 2021-06-18
  • 2022-01-29
  • 2022-12-23
  • 2021-09-14
  • 2022-01-01
  • 2021-07-10
  • 2021-10-15
  • 2022-12-23
猜你喜欢
  • 2021-11-11
  • 2021-09-01
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-03-01
相关资源
相似解决方案