• 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 do i retrieve and display the alt text of an image in wordpress?

Implode array with array of glue strings

OctoberCMS / Anonymous Global Scope

How to insert Google Adsense Code in PHP script?

Passing a boolean value from checkbox in Laravel form

What is the difference between client-side and server-side programming?

google content api for shopping

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

Laravel Collections. Is there some kind of assertStructure method?

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource [duplicate]

PHP Startup: Unable to load dynamic library 'openssl' in Ubuntu

hidden INPUT value not available in $_POST

Laravel dosen't connect with Oracle

Required field only if another field has a value, must be empty otherwise

How to get quarter for future date using Carbon?

About Contact Privacy policy Terms and conditions