I created two php classes separately. those are Student.php and Main.php this is my code.
this is my 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;
}
}
?>
this is my Main.php
<?php
class Main{
function show() {
$obj =new Student("mssb", "24");
echo "Print :".$obj->display1();
}
}
$ob = new Main();
$ob->show();
?>
so my problem is when I call taht show method it gives Fatal error: Class 'Student' not found what is the wrong in here. is it necessary to import or something? please help me.