• 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

php - add comma thousands separator but remove trailing zeros

Symfony redirect if already loggedin from login page

php curl requesting twice

Laravel implode array items to new lines

Convert every two values of an associative array into key-value pairs

PHP -> Next nearest date defined by array of days in week

How can I solve "laravel/horizon v1.1.0 requires ext-pcntl * -> the requested PHP extension pcntl is missing from your system"?

What is PHP's equivalent of JavaScript's "array.every()"?

How to load Codeigniter 4 lang file into an array variable

Upgrade PHP on AWS Linux

java URL working on browser but not in client program

image source not readable

Combine array with same value and add other [duplicate]

Pagekite error: FAIL: localhost:8080 is down

Search for array row with specific column value and return another value from qualifying row

About Contact Privacy policy Terms and conditions