• 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 Warning: Module already loaded in Unknown on line 0

Webscraping Symfony/Panther: Can't get HTML

PHP: Calling MySQL Stored Procedure with Both INPUT AND OUTPUT Parameters (NOT "INOUT")

retrieve data from database using session

Target class controller does not exist - Laravel 8

Multiple order by in WooCommerce

Laravel no logout option from menu after successfull login

Dynamic dropdown Ajax PHP request

how do i retrieve and display the alt text of an image in wordpress?

Adding one microsecond to Datetime object in PHP

How to remove index.php and index from the URL using htaccess | PHP

Match csv filenames to table names and import

Filter array by skipping every nth element from the end

How can I access an array/object?

could not find driver Debian SQL Server PHP

About Contact Privacy policy Terms and conditions