

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
PHP http://
Introduction
The http:// and https:// wrappers enable read only access to resources and files through HTTP procol. When handling virtual name-based host, host: header is also sent along with user_agent (if configured in php.ini)
The http header information is stored in $http_response_header variable. These headers have to be processed to know URL of resource where the document comes from with the help of from: header.
HTTPS is supported only if openssl extension is enabled in php.ini settings. Both HTTP and HTTPS connections are read only and don't support writing or copying files.
Usage
Representation of file name in different possible ways is as follows −
http://localhost http://example.com http://localhost?name='Ram'&age=20 https://example.com http://username:password@abc.com
Example
<?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); ?>
Above script reads header metadata from 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 )
- Related Questions & Answers
- PHP HTTP context options
- PHP – Detect HTTP input character encoding with mb_http_input()
- What is HTTP?
- PHP – Get or set the HTTP output character encoding with mb_http_output()
- How to add http:// if it doesn't exist in the URL PHP?
- Making http request in React.js
- Sending Http Requests in ReactJS
- Difference Between HTTP and HTTPS
- Understanding the http requests in Node
- Checking HTTP Status Code in Selenium.
- HTTP Requests with axios in ReactJS
- Sending HTTP error code using Express.js
- How to read a HTTP header using JSP?
- What is Http/2 Client in Java 9?
- Differentiate between HTTP and HTTPS in Computer Network.
Advertisements