• 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 write PHP in XSLT

PHP - CURL using HTTPS [closed]

JQuery content editable div and text box on submit not sending POST

how to remove %20 in the url in php

Display the WooCommerce product price inside a custom function

How to properly set "0000-00-00 00:00:00" as a DateTime in PHP

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

Laravel 5 session not persisting after user is logged in

Laravel 5.1 how to use {{ old('') }} helper on blade file for radio inputs

Unsure why I am getting: Number of variables doesn't match number of parameters in prepared statement

how to upload binary image to sql server using php laravel

How Can I Do LIMIT 1, 2 In WP_Query

PHPMyAdmin not working as intended at remote server. Error 500, $respond not found

WordPress - Dynamically add user ID to the end of a URL

How to get AJAX to post on second page?

About Contact Privacy policy Terms and conditions