PHP http://
簡介
http://和https://包裝器透過 HTTP 協議啟用對資源和檔案的只讀訪問。當處理基於虛擬名稱的主機時,host:標頭也會與user_agent一起傳送(如果在 php.ini 中配置)。
http 標頭資訊儲存在$http_response_header變數中。必須處理這些標頭才能藉助from:標頭瞭解文件來源的資源 URL。
僅當在 php.ini 設定中啟用了openssl擴充套件時才支援 HTTPS。HTTP 和 HTTPS 連線都是隻讀的,不支援寫或複製檔案。
用法
檔名的不同可能表示如下 −
https:// http://example.com https://?name='Ram'&age=20 https://example.com http://username:password@abc.com
示例
<?php
$url = 'https://tutorialspoint.tw/php7/php7_closure_call.htm';
if (!$fp = fopen($url, 'r')) {
trigger_error("Unable to open URL ($url)", E_USER_ERROR);
}
$meta = stream_get_meta_data($fp);
print_r($meta);
?>以上指令碼從 http URL 讀取標頭元資料
Array( [crypto] => Array( [protocol] => TLSv1.2 [cipher_name] => ECDHE-RSA-AES128-GCM-SHA256 [cipher_bits] => 128 [cipher_version] => TLSv1/SSLv3 ) [timed_out] => [blocked] => 1 [eof] => [wrapper_data] => Array( [0] => HTTP/1.0 200 OK [1] => Age: 1310067 [2] => Cache-Control: max-age=2592000 [3] => Content-Type: text/html; charset=UTF-8 [4] => Date: Mon, 14 Sep 2020 17:15:36 GMT [5] => Expires: Wed, 14 Oct 2020 17:15:36 GMT [6] => Last-Modified: Sun, 30 Aug 2020 13:21:09 GMT [7] => Server: ECS (nag/99AA) [8] => Strict-Transport-Security: max-age=63072000; includeSubdomains [9] => Vary: Accept-Encoding [10] => X-Cache: HIT [11] => X-Content-Type-Options: nosniff [12] => X-Frame-Options: SAMEORIGIN [13] => X-XSS-Protection: 1; mode=block [14] => Content-Length: 24102 [15] => Connection: close ) [wrapper_type] => http [stream_type] => tcp_socket/ssl [mode] => r [unread_bytes] => 0 [seekable] => [uri] => https://tutorialspoint.tw/php7/php7_closure_call.htm )
廣告
資料結構
網路
RDBMS
作業系統
Java
iOS
HTML
CSS
Android
Python
C 程式設計
C++
C#
MongoDB
MySQL
Javascript
PHP