• 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

WordPress + Nginx on non-standard port behind AWS ELB results in broken links

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

passwordless LDAP login and get user information using Kerberos ticket in PHP

Laravel database insert with combining array and string

How can I easily switch between PHP versions on Mac OSX?

Can we define variables in `.tpl` files?

xdebug 3 not working in ubuntu 20.04 with docker

Creating live search with AJAX and CodeIgniter

Laravel Excel::store file empty after stored

Comma separated list from array with "and" before last element

500 Internal Server Error on Ajax request. Not sure the origin of the problem

WAMP/Wordpress - cURL error 28: Operation timed out after 10001 milliseconds with 0 bytes received

Getting output of MS stored procedure on php call

Composer Script echo

How to check user Permissions using Custom Middleware in Laravel

About Contact Privacy policy Terms and conditions