(spl_autoload_register)函数出现问题

时间:2019-06-20 11:53:11

标签: php

    <?php

spl_autoload_register('myAutoloader');

    function myAutoloader($className){

        $path = "classes/";
        $extension = ".class.php";
        $fullPath = $path . $className . $extension;

        include_once $fullPath;

    }


?>
<!DOCTYPE html>
<html>
<head>
    <title></title>
</head>
<body>
    <?php


        $student = new Students();
        $student->get_stu_report('Ahmad', '01', '35/50');
        echo $student->stu_name . "<br />";
        echo $student->stu_roll_no . "<br />";
        echo $student->stu_marks . "<br />";

        $student1 = new Students();
        $student1->get_stu_report('Muhammad', '02', '44/50');
        echo $student1->stu_name . "<br />";
        echo $student1->stu_roll_no . "<br />";
        echo $student1->stu_marks . "<br />";

        $student2 = new Students();
        $student2->get_stu_report('Tabish', '03', '41/50');
        echo $student2->stu_name . "<br />";
        echo $student2->stu_roll_no . "<br />";
        echo $student2->stu_marks . "<br />";



        $teacher1 = new Teachers();
        $teacher1->get_teachers_results('Prof Amir', '88%', '93%');
        echo $teacher1->teacher_name . "<br />";
        echo $teacher1->teacher_math_result . "<br />";
        echo $teacher1->teacher_english_result . "<br />";

        $teacher2 = new Teachers();
        $teacher2->get_teachers_results('Prof Asad Umar', '91%', '63%');
        echo $teacher2->teacher_name . "<br />";
        echo $teacher2->teacher_math_result . "<br />";
        echo $teacher2->teacher_english_result . "<br />";

        $teacher3 = new Teachers();
        $teacher3->get_teachers_results('Prof Uzair', '43%', '52%');
        echo $teacher3->teacher_name . "<br />";
        echo $teacher3->teacher_math_result . "<br />";
        echo $teacher3->teacher_english_result . "<br />";




    ?>


</body>
</html>
  
    

警告:include_once(classes / Students.class.php):无法打开流:在目录中没有这样的文件或目录     第11行的C:\ xampp \ htdocs \ Object_Oriented \ index.php

  
     

警告:include_once():无法打开“ classes / Students.class.php”   用于包含(include_path ='C:\ xampp \ php \ PEAR')   第11行的C:\ xampp \ htdocs \ Object_Oriented \ index.php

     

致命错误:找不到“学生”类   C:\ xampp \ htdocs \ Object_Oriented \ index.php在第26行

请帮助我解决这些错误,谢谢

0 个答案:

没有答案