SRV record lookup with PHP(使用 PHP 查找 SRV 记录)
问题描述
如果你输入
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 记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:使用 PHP 查找 SRV 记录
基础教程推荐
- PHP PDO MySQL 查询 LIKE ->多个关键词 2021-01-01
- YouTube API v3 点赞视频,但计数器不增加 2022-01-01
- PHP 类:全局变量作为类中的属性 2021-01-01
- 如何在 Laravel 中使用 React Router? 2022-01-01
- Cron Jobs 调用带有变量的 PHP 脚本 2022-01-01
- 如何替换eregi() 2022-01-01
- 有什么方法可以用编码 UTF-8 而不是 Unicode 返回 PHP`json_encode`? 2021-01-01
- 在PHP中根据W3C规范Unicode 2022-01-01
- 学说 dbal querybuilder 作为准备好的语句 2022-01-01
- 如何在 Laravel 5.3 注册中添加动态下拉列表列? 2021-01-01
