• Categories
    • PHP
    • phpMyAdmin
    • PHPMailer
    • FFMpeg
    • PHPEXcel
    • PHPDoc
    • PHPUnit
    • CakePHP
    • CakePHP 2.0
    • Cake PHP 2.1
    • CakePHP Model
    • Facebook PHP SDK
    • composer-php
    • PHP 7
    • PHP GD
    All Categories
  • About

file_get_contents() without "Http" to access external URL [closed]

php


PHP Snippet 1:

<?php

$ctx = stream_context_create(array(
    'http' => array(
        'timeout' => 16.0 // seconds
    )
));

$contents = file_get_contents('http://...', FALSE, $ctx);

// do something with $contents

PHP Snippet 2:

$ ./test
{
  "headers": {
    "Host": "httpbin.org"
  }
}

$ cat test
#!/usr/bin/env php
<?php

die(file_get_contents('http://httpbin.org/headers'));

Related Snippets

Transpose and flatten multiple rows of array data [duplicate]

disable two buttons after clicking another button

PHP each() function replacement

How to make a array inside array?

Unable to match results of php hash_hmac() and coldfusion hmac()

Laravel/docker-compose/redis - Class 'Redis' not found

How to create laravel storage symbolic link for production or sub domain system?

Laravel 8: Array to string conversion while calling route:list

Not able to override collapsible.js in magento 2

Array to string conversion

PHP - Store information with NO database

PHPExcel_IOFactory::createWriter causes wrong behaviour

Cannot retrieve error message using Symfony HttpClient if the response is not "ok"

VichUploaderBundle error "Expected argument of type "File", "NULL" given" when submitting the form without selecting any file

How to fix " Uncaught TypeError: Argument 1 passed to JpGraphException::defaultHandler() " problem in php 7.1.3 and jpgraph 4.2.6?

About Contact Privacy policy Terms and conditions