PHP code example of zero-to-prod / stream-context
1. Go to this page and download the library: Download zero-to-prod/stream-context library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
zero-to-prod / stream-context example snippets
use Zerotoprod\StreamContext\StreamContext;
use Zerotoprod\StreamContext\DataModels\Options;
use Zerotoprod\StreamContext\DataModels\Http;
$client = stream_socket_client(
'ssl://neverssl.com:443',
$error_code,
$error_message,
30,
STREAM_CLIENT_CONNECT,
StreamContext::create([
Options::http => [
Http::method => 'GET',
Http::header => "Accept-language: en\r\n"."Cookie: foo=bar",
Http::proxy => 'proxy'
],
['options']
])->context
);
fclose($client);