【发布时间】:2012-08-21 02:30:49
【问题描述】:
我分别创建了两个 php 类。这些是 Student.php 和 Main.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 方法时,它会给出 致命错误:未找到“学生”类这里出了什么问题。有必要进口吗?请帮帮我。
【问题讨论】:
标签: php