• 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

how to remove %20 in the url in php

Google Gmail API - How to login programatically?

Class AppHttpControllersUserController Does Not Exist

Why the name of trucks are same in 2nd and 3rd record of company data retrieval?

advanced custom fields wordpress custom class

how to redirect the user back to desired URL after login page in PHP?

How to reset Laravel AuthManager/guards in between API calls in tests?

PHP header location absolute URL

How to get array values using foreach in laravel

xdebug 3 not working in ubuntu 20.04 with docker

Laravel Mixing of GROUP columns (MIN(),MAX(),COUNT(),...) on a sub query with "ROW_NUMBER() OVER PARTITION"

Insert multidimensional array to codeigniter cart

Laravel 5 issue with wherePivot

Transpose csv file data [duplicate]

500 Internal Server Error on Ajax request. Not sure the origin of the problem

About Contact Privacy policy Terms and conditions