Computer >> 컴퓨터 >  >> 프로그램 작성 >> PHP

PHP https://

<시간/>

소개

https:// https:// 래퍼는 HTTP 프로토콜을 통해 리소스와 파일에 대한 읽기 전용 액세스를 가능하게 합니다. 가상 이름 기반 호스트를 처리할 때 호스트: 헤더도 user_agent와 함께 전송됩니다. (php.ini에서 설정한 경우)

http 헤더 정보는 $http_response_header에 저장됩니다. 변하기 쉬운. 이러한 헤더는 출처:의 도움으로 문서가 출처인 리소스의 URL을 알기 위해 처리되어야 합니다. 헤더.

HTTPS는 openssl인 경우에만 지원됩니다. 확장은 php.ini 설정에서 활성화됩니다. HTTP 및 HTTPS 연결은 모두 읽기 전용이며 파일 쓰기 또는 복사를 지원하지 않습니다.

사용

다른 가능한 방법으로 파일 이름을 나타내는 것은 다음과 같습니다 -

https://localhost
https://example.com
https://localhost?name='Ram'&age=20
https://example.com
https://username:password@abc.com

예시

<?php
$url = 'https://www.tutorialspoint.com/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://www.tutorialspoint.com/php7/php7_closure_call.htm
)