php get_file_contents header code example
Example 1: php file_get_contents
<?php
$homepage = file_get_contents('http://www.example.com/');
echo $homepage;
?>
Example 2: file_get_contents header
$opts = [
"http" => [
"method" => "GET",
"header" => "Accept-language: en\r\n" .
"Cookie: foo=bar\r\n"
]
];
$context = stream_context_create($opts);
$file = file_get_contents('http://www.example.com/', false, $context);
Example 3: turn text file to string php
$fileContent = file_get_contents($url);
Example 4: transfer file using file_get_content
$header = 'Content-Type: multipart/form-data; boundary='.MULTIPART_BOUNDARY;