• 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

dockerizing Laravel + vue

How to convert the int value to inch in PHP [closed]

How to upload mpdf file after generating to s3 bucket in php

Convert PHP array into HTML tag attributes separated by spaces

How to find the date a user created their Google account

Json_Encode not returning html even i try to encode JSON_HEX_QUOT | JSON_HEX_TAG

Make Shipping Method fields Mandatory on Woocommerce checkout page

advanced custom fields wordpress custom class

How do I get friend list from Friends table with counts of friends of my friends

Sagepay Error The Vendor failed to provide a RedirectionURL

PHPSpreadsheet - How Do I Use Auto Migration Tool

How can I make this nested location configuration use the correct path to call a php program?

How to insert Google Adsense Code in PHP script?

Hide specific products from unlogged users based in product category in WooCommerce

how to search for a file with php

About Contact Privacy policy Terms and conditions