开发者

PHP class name from variable with "class not found" check?

I'm trying to implement the strategy pattern in PHP, creating objects with variable variables as follows:

$className = 'MyClass';
$myObject = new $className();

Is there a way to verify that $cla开发者_如何转开发ssName exists as a Class?


class_exists($className)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜