本文介绍了PHP 5.3.2:实例化对象的方法已弃用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
白屏死机,所以决定远程调试一个我怀疑正在使用现在不支持的方法实例化对象的应用程序:
Getting a white screen of death, so decided to remote debug an application that I suspect is instantiating an object using a now unsupported method:
$ type ['content_object'] = new $ type ['handler_class']();
这仍然合法吗?
推荐答案
假设 $ type ['handler_class']
是包含以下名称的字符串一个类,那么根据:
Assuming $type['handler_class']
is a string containing the name of a class, then it's fine, according to the manual:
<?php
$instance = new SimpleClass();
// This can also be done with a variable:
$className = 'Foo';
$instance = new $className(); // Foo()
?>
这篇关于PHP 5.3.2:实例化对象的方法已弃用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!