当我执行一个PHP脚本,该脚本运行一个URL到.test域的cURL请求时,该域在Mac上使用Laravel Valet / dnsmasq进行了设置,我得到此错误消息:
无法解析:mydomain.test(找不到域名)
当我在浏览器中测试域时,就可以了。
当我curl -Ik https://mydomain.test在终端中运行时,我获得了HTTP / 2 200代码,因此可以。
当我curl -k https://mydomain.test在终端中运行时,我得到了页面的源代码,因此可以。
为什么它不能与PHP中的cURL一起使用?我很绝望...
更新
由于受欢迎的需求;-)这是我的cURL代码。您不能做得更简单:
try {
$ch = curl_init( "http://mydomain.test" );
curl_exec( $ch );
dump(curl_error($ch));
curl_close( $ch );
} catch (Exception $e) {
var_dump($e);
}
Run Code Online (Sandbox Code Playgroud)