В linux bash я запускаю:
Код: Выделить всё
curl https://google.com -vI
Код: Выделить всё
--- (more text before...)
* Server certificate:
* subject: CN=*.google.com
* start date: Oct 7 08:23:38 2024 GMT
* expire date: Dec 30 08:23:37 2024 GMT
* subjectAltName: host "google.com" matched cert's "google.com"
* issuer: C=US; O=Google Trust Services; CN=WR2
* SSL certificate verify ok.
--- (more text after...)
Я хочу сделать то же самое в PHP с помощью этого кода:
Код: Выделить всё
$url = "https://google.com/";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_VERBOSE, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$RAWresponse = curl_exec($ch);
dd($RAWresponse);
Код: Выделить всё
HTTP/1.1 301 Moved Permanently
Location: https://www.google.com/
Content-Type: text/html; charset=UTF-8
Content-Security-Policy-Report-Only: object-src 'none';base-uri 'self';script-src 'nonce-Jfg7vMsTbRraHV67JGhJ2w' 'strict-dynamic' 'report-sample' 'unsafe-eval'
Date: Fri, 08 Nov 2024 00:47:17 GMT
Expires: Sun, 08 Dec 2024 00:47:17 GMT
Cache-Control: public, max-age=2592000
Server: gws
Content-Length: 220
X-XSS-Protection: 0
X-Frame-Options: SAMEORIGIN
Alt-Svc: h3=":443"; ma=2592000,h3-29=":443"; ma=2592000
301 Moved
301 Moved
The document has moved
[url=https://www.google.com/]here[/url].
Спасибо!
Подробнее здесь: https://stackoverflow.com/questions/791 ... -line-curl