抱歉,如果这是真正的基础,但当
PHP进入功能时,我已经超过了我的头脑.
我有一个论坛的插件,它加载一个flash cookie作为检测重复帐户的方法.
该脚本在大约0.1%的页面视图上失败,从而导致WSOD.错误指向此行:
return $this->registry->output->getTemplate( 'dml' )->duplicatesLoadMovie( $host, $path, $id, $md5 );
而错误是:
Fatal error: Call to a member function duplicatesLoadMovie() on null in /var/www/…/web/forums/hooks/duplicatesLoadMovie.php on line 75
对我来说,这是$host,$path,$id或$md5中的一个返回null,但由于这不是我的脚本(编码器当然没有响应),我想解决这个问题.最简单的方法(除了删除它,这是后备位置).
如果id.null,我可以简单地做一些$id = 0的效果吗? (对不起Rubyspeak)每个$变量?
该文件的完整来源:
class duplicatesLoadMovie
{
/**
* Registry object shortcuts
*
* @var $registry
* @var $settings
* @var $member
* @var $memberData
**/
public $registry;
public $settings;
public $member;
public $memberData;
/**
* Main function executed automatically by the controller
*
* @access public
* @return @e void
**/
public function __construct()
{
$this->registry = ipsRegistry::instance();
$this->settings =& $this->registry->fetchSettings();
$this->member = $this->registry->member();
$this->memberData =& $this->registry->member()->fetchMemberData();
}
/**
* Get the output
*
* @access public
* @return @e string
**/
public function getOutput()
{
/* Grab host URL and installation path of the community */
$host = $this->settings['board_url'];
$parsed = parse_url( $host );
$path = trim( $parsed['path'], '/' );
if( $path == '' )
{
$path = '/';
}
$host = 'host=' . $host;
$path = 'path=' . $path;
/* Determine the appropriate identification method (member_id for members and session_id for guests) */
if( $this->memberData['member_id'] )
{
$id = 'mid=' . $this->memberData['member_id'];
}
else
{
$id = 'sid=' . $this->member->session_id;
}
/* Grab the secure key for AJAX */
$md5 = 'md5=' . $this->member->form_hash;
/* Finally, call the template bit */
return $this->registry->output->getTemplate( 'dml' )->duplicatesLoadMovie( $host, $path, $id, $md5 );
}
最佳答案 我怀疑这个getTemplate(‘dml’)没有返回值.如果你做一个var_dump(getTemplate(‘dml’)),它会显示什么吗?
您可以在执行该行代码之前检查“null”,并在“else”语句中输出错误消息或其他适合该错误的操作.