• 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

Laravel You requested 1 items, but there are only 0 items available

Edit product hook WooCommerce

How to get multiple values with same key from an array PHP

How to use functions that are declared in snippets in Evolution CMS (Modx) in an external PHP Script?

How to get quarter for future date using Carbon?

Dynamic table in HTML using MySQL and php

Can't call javascript alert alertify library from PHP

Cut an arabic string

How to add a custom field to all Woocommerce attribute terms using add_action

Yii2: How to download backup files using spanjeta/yii2-backup?

Unable to guess the mime type as no guessers are available Laravel 5.2

laravel sanctum Route [login] not defined

php file upload scanning using clamav, permissions on /tmp/

Merge column values from two arrays to form an indexed array of associative arrays

RabbitMQ PRECONDITION_FAILED - unknown delivery tag

About Contact Privacy policy Terms and conditions