class_exists($className) ambiguous output

i am checking if (class_exists($className));

Here the class i am checking is a Model Class to create its object if exists.

I dont want to autoload the class just want Checked whether it Exists or Not.

Problem:

if use the 2nd param autoload=false =>


(class_exists($m, FALSE))

it returns False for the correct class name too.

without 2nd param =>


(class_exists($m))

if class exists it loads


if Not it tries to include the class & gives an PHP Error

i know the class may not exists so giving the FALSE autoload param to avoid PHP Error.

but the mere purpose of the class_exists function is not justifying.

The function where i am checking the class exists:


public function getNewModel($modelName = NULL) {

	$m;

	if ($modelName !== NULL)

		$m = $modelName;

	else

		$m = $this->_mn;


// have to use with false but then even for correct class name giving exception.

//	if (class_exists($m))

	if (class_exists($m,FALSE)) 

		return new $m;

	else

		throw new CHttpException(0, "Model Class Name: '" . $modelName . "'");

}



The error generated when the do not exists.


Description


include(p.php) [<a href='function.include'>function.include</a>]: failed to open stream: No such file or directory


Source File


D:\wamp\www\yii\framework\YiiBase.php(395)


00385:     public static function autoload($className)

00386:     {

00387:         // use include so that the error PHP file may appear

00388:         if(isset(self::$_coreClasses[$className]))

00389:             include(YII_PATH.self::$_coreClasses[$className]);

00390:         else if(isset(self::$classMap[$className]))

00391:             include(self::$classMap[$className]);

00392:         else

00393:         {

00394:             if(strpos($className,'\\')===false)

00395: include($className.'.php');

00396:             else  // class name with namespace in PHP 5.3

00397:             {

00398:                 $namespace=str_replace('\\','.',ltrim($className,'\\'));

00399:                 if(($path=self::getPathOfAlias($namespace))!==false)

00400:                     include($path.'.php');

00401:                 else

00402:                     return false;

00403:             }

00404:             return class_exists($className,false) || interface_exists($className,false);

00405:         }

00406:         return true;

00407:     }



i could not understand line 00404 and 00395, its actually trying to include the class before checking it exists so outputing error.

So how this function is supposed to run and output. or am i wrong somewhere?

does no body has problem like this?

i found few other posts like this not any solution.