• 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

CodeIgniter extend CI_URI undefined method

How to create a individual template for page or post in custom plugin?

Laravel 5 issue with wherePivot

PhP how to calculate moments with variables rows

How to install LDAP in Docker php-fpm alpine

Custom add to cart button URL for specific product in WooCommerce?

I need to link Google Sheet with my Laravel

correct PHP headers for pdf file download

How to disable widget block editor of WordPress?

Converting IPv6 to IPv4 address in PHP

Show rotation of tweets using current day of month

Adding reCAPTCHA v2 into my PHP file

phpMyAdmin ERROR: mysqli_real_connect(): (HY000/1045): Access denied for user 'pma'@'localhost' (using password: NO)

Laravel 5 controller sending JSON integer as string

how to use extended ASCII instead of unicode in PHP

About Contact Privacy policy Terms and conditions