• 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

Docker & Laravel : configure: error: Package requirements (oniguruma) were not met

Image upload not working through ajax Laravel

Laravel Database Strict Mode

HTML + PHP + PHPMAILER

Laravel 4 Redirect::back() not going to previous page (refreshing current page)

IlluminateDatabaseQueryException: SQLSTATE[HY000]: General error: 1 no such table - In clone project

Issue with laravel eloquent model property

How should I get started using PHPUnit as a testing framework for a bunch of functions and classes I have already made?

PHP, how to convert Int value to Week days

PHP Deprecated issue when running artisan command

Sum array values

Woocommerce redirect after add-to-cart error

Substitute integers and dots with regex [duplicate]

How to validate Envato Purchase Code in PHP

How to find the date a user created their Google account

About Contact Privacy policy Terms and conditions