• 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 avoid Moved Permanently The document has moved here

how to see if database exists with PDO [duplicate]

How to find phpcs current default standard

Which is faster php date functions or carbon?

PHP echo values of all sub keys [duplicate]

Transform array, set each array element with parent key php

How to update array value in Laravel

Adding reCAPTCHA v2 into my PHP file

Toggle between a textbox and a select using PHP

How to fix this error : Ask your hosting provider to use PHP 7.2.5 or higher for both HTTP and CLI?

Project structure for PHP

Get WooCommerce products from specific category

Handle error for duplicate entries - PHP/MySQL

PHPSpreadsheet - How Do I Use Auto Migration Tool

(Cache::lock()) -> get() -- Under what conditions does it return false?

About Contact Privacy policy Terms and conditions