我的“我的包含”文件夹中有这样的php文件,
newclass.int.php
<?php
class NewClass extends ParentClass {
}
?>
parentclass.int.php
<?php
class ParentClass{
public $name = "Hey There!";
}
?>
和index.php
这样
<?php
include 'includes/parentclass.int.php';
include 'includes/newclass.int.php';
$object = new NewClass;
?>
<html>
<head>
<title>oop php</title>
</head>
<body>
<?php
echo $object->name;
?>
</body>
</html>
但是运行服务器时出现以下错误消息
Warning: include(includes/parentclass.int.php): failed to open stream: No such file or directory in C:\wamp64\www\ooptest\index.php on line 2
Warning: include(includes/newclass.int.php): failed to open stream: No such file or directory in C:\wamp64\www\ooptest\index.php on line 3
Fatal error: Uncaught Error: Class 'NewClass' not found in C:\wamp64\www\ooptest\index.php on line 4
Error: Class 'NewClass' not found in C:\wamp64\www\ooptest\index.php on line 4
如何解决此问题?
答案 0 :(得分:0)
显示给定的错误是因为您要在第 2 行中尝试包含的文件在指定路径下不存在。
确保 parentclass.int.php 位于以下路径中:C:\ wamp64 \ www \ ooptest \ includes \