getmxrr和Deprecated:调用时传递引用

时间:2012-05-28 13:41:13

标签: php error-handling

getmxrr的PHP文档将语法指定为

bool getmxrr ( string $hostname , array &$mxhosts [, array &$weight ] )

此功能未折旧(不会被更受青睐的功能所取代)。但是,当使用上述功能时,我收到此警告:

  

不推荐使用:已弃用调用时间传递引用   第n行的路径/到/脚本

那么,如何在不引起PHP抱怨的情况下使用该实用程序?

语言对自己的处方不满意是不是很荒谬?

1 个答案:

答案 0 :(得分:4)

这不是你应该怎么称呼的;该函数声明了引用,它并不打算在调用时使用。

$mxhosts = $weight = array(); // not really necessary but good for form :)
$res = getmxrr('example.com', $mxhosts, $weight);
// $mxhosts and $weight are populated

另请参阅:http://php.net/manual/en/language.references.pass.php

相关问题