• 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

Star and Half Star Rating in Laravel

Increase value by 1 on button click

MOODLE: What does it mean to aggregate h5p assets?

args[max_input] woocommerce if statement confused

How to get page number on dompdf PDF when using "view"

Add a custom text for a particular product on specific email notification in Woocommerce

nginx err_connection_refused, can anyone help me?

Laravel 5.1 xmlHttpRequest AJAX POST TokenMismatchException

api response laravel doesn't show

Laravel insert dynamic input values with radio button

Sync Records With Default Values in Pivot Tables, Call to undefined method syncWithPivotDefaults()

How to set dynamic `home` and `siteurl` in WordPress?

merge all files in directory to one text file

Laravel excel maatwebsite 3.1 import, date column in excel cell returns as unknown format number. How to solve this?

Edit product hook WooCommerce

About Contact Privacy policy Terms and conditions