Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/228.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
PHP:无法识别同一目录中的类文件?_Php_Class_Oop - Fatal编程技术网

PHP:无法识别同一目录中的类文件?

PHP:无法识别同一目录中的类文件?,php,class,oop,Php,Class,Oop,我在同一目录中有两个php文件: test.tattler.php class.tattler_stats.php 我的test.tattler应该创建我的tattler_stats的对象,但它给了我以下错误: Fatal error: Class 'tattler_stats' not found in /.../test.tattler.php on line 4 test.tattler中的代码: <?php include 'class.tattler_stats.php';

我在同一目录中有两个php文件:

test.tattler.php
class.tattler_stats.php
我的test.tattler应该创建我的tattler_stats的对象,但它给了我以下错误:

Fatal error: Class 'tattler_stats' not found in /.../test.tattler.php on line 4
test.tattler中的代码:

<?php

include 'class.tattler_stats.php';

$tattler_test = new tattler_stats( $_REQUEST );

?>

确保您在类文件中实际声明了类

class tattler_stats {
    // class code here
}
如果已经这样做了,请尝试更具体地指定路径:

include(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'class.tattler_stats.php');

确保您在类文件中实际声明了类

class tattler_stats {
    // class code here
}
如果已经这样做了,请尝试更具体地指定路径:

include(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'class.tattler_stats.php');