• 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

sort() not affecting original array while inside foreach loop

jQuery Ajax Post with data

Laravel PackageManifest.php: Undefined index: name

Install mysql client in docker image

Use same method for inertia response and json response Laravel Jetstream

php code to send checkbox form results to email

phpmyadmin : Depends: php-twig (>= 2.9) but 2.6.2-2 is to be installed. WHAT?

Laravel Collections. Is there some kind of assertStructure method?

Best way to scrolldown onpageload

Facebook SDK error: Cross-site request forgery validation failed. Required param "state" missing from persistent data

SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'name' cannot be null

MySQL default time format UTC or GMT?

How to render html from a @foreach loop in a textarea

calling server using nusoap with complextype

How to add a heading in between checkout fields of WooCommerce

About Contact Privacy policy Terms and conditions