我分别创建了两个php类。这些是Student.php和Main.php这是我的代码。如何使用PHP调用另一个类中的方法
这是我Student.php
<?php
class Student {
private $name;
private $age;
function __construct($name, $age) {
$this->name = $name;
$this->age = $age;
}
function setName($name){
$this->name = $name;
}
function setAge($age){
$this->age = $age;
}
function getName() {
return $this->name;
}
function getAge() {
$this->age;
}
function display1() {
return "My name is ".$this->name." and age is ".$this->age;
}
}
?>
这是我Main.php
<?php
class Main{
function show() {
$obj =new Student("mssb", "24");
echo "Print :".$obj->display1();
}
}
$ob = new Main();
$ob->show();
?>
所以我的问题是,当我打电话taht show方法它给致命错误: '学生'没有找到这里有什么问题。是否需要导入或什么?请帮帮我。