• 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

I want to use codeigniter foreign character library in my custom PHP project how i can use it?

Shortcode or PHP inside a shortcode in Wordpress

MOODLE: What does it mean to aggregate h5p assets?

Prestashop cUrl Login

JQuery content editable div and text box on submit not sending POST

PHP and WebView - Cookie doesn't are the same

Execute only one time and then wait set period of time before executing again

How to display table header in every page using FPDF library?

Problem with fetching data from database in Laravel

Wordpress add responsive srcset header image to theme

laravel controller function parameters

Getting output of MS stored procedure on php call

Nginx disallowing execution of PHP in uploads directory with Magento

Calculating Median of an array in PHP

How can I pass the list to the component variable in Laravel?

About Contact Privacy policy Terms and conditions