Yii Framework Forum: Class_Exists方法老是报Include的500错误,如何正确捕获? - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Class_Exists方法老是报Include的500错误,如何正确捕获? Rate Topic: -----

#1 User is offline   Jackie.li 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 2
  • Joined: 23-May 11

Posted 20 November 2012 - 12:58 AM

先上代码:
$newClass = "GameX";
if(class_exists($newClass))
{
    $m  = new $newClass();
}else{
    //类不存在的逻辑
}
var_dump($m);


此时如果GameX这个类存在的话是没有问题的。
但如果GameX确实不存在,此时会爆一个include(GameX.php)的500错误


如何能够正确的捕获呢?

我网上查了下如果将if语句修改为 class_exists($newClass,false)的话
这个判断永远就只能返回false了,因为禁用了自动加载功能。。。。。。


求支招。
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users