如果你输入
nslookup -type=SRV _xmpp-server._tcp.gmail.com
(或在 OSX 中使用 dig 命令)你会得到一些与谷歌聊天相关的 SRV 记录
(or use the dig command in OSX) you get some SRV records relating to google chat
我想在 PHP 中复制这个功能,有没有人有什么好的想法如何做到这一点?
I would like to replicate this functionality in PHP, does anyone have any good ideas how to do this?
我想避免使用 exec(),因为这不会在 OSX/*NIX/WINDOWS 中返回 100% 的标准响应
I would like to avoid using exec() as this does not return 100% standard responses across OSX/*NIX/WINDOWS
谢谢!
你可以使用 Pear Net_DNS一>.我设法让它在 Linux 上运行,但还没有在 Windows 或任何其他平台上测试过:
You could use Pear Net_DNS. I managed to get this to work on Linux, but haven't tested it on Windows or any others:
require_once('Net/DNS.php');
$resolver = new Net_DNS_Resolver();
$response = $resolver->query('_xmpp-server._tcp.gmail.com', 'SRV');
if ($response) {
foreach ($response->answer as $rr) {
$rr->display();
}
}
我修改了他们文档中的示例.希望这有帮助
I modified the example from their documentation. hope this helps
这篇关于使用 PHP 查找 SRV 记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!