Cosmin
Cosmin

Reputation:

PHP: Class file in the same directory not being recognized?

I have two php files in the same directory:

test.tattler.php
class.tattler_stats.php

My test.tattler is supposed to create an object of my tattler_stats but it gives me this error:

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

Code in test.tattler:

<?php

include 'class.tattler_stats.php';

$tattler_test = new tattler_stats( $_REQUEST );

?>

The code in tattler_stats:

function __construct( $_REQUEST )
{
    $param = $_REQUEST['menu'];

    run();
}

function run()
{
    connect();
    showMenu( $parm ) ;
//rest of class...

Upvotes: 2

Views: 3283

Answers (1)

Brian Ramsay
Brian Ramsay

Reputation: 7635

make sure you're actually declaring the class in your class file

class tattler_stats {
    // class code here
}

if you are already doing that, try specifying the path more concretely:

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

Upvotes: 1

Related Questions