• 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

image source not readable

Class AppHttpControllersUserController Does Not Exist

Undefined Array Key error when uploading image on php

How to assert parameter attribute sub-structures in PHPUnit mock call expectations

Laravel 5 issue with wherePivot

php code to send checkbox form results to email

Override default Auth routes in Laravel 7

"Notice: Undefined variable", "Notice: Undefined index", "Warning: Undefined array key", and "Notice: Undefined offset" using PHP

backup files to google drive using PHP

Yii Ajax Submit button

Respond with status code 401 on authentication failure using Laravel and Passport?

How to create a video stream from a single dynamic image in PHP

PHPExcel file download using AJAX call

I want to display default profile image if user do not have profile image

Laravel: HTML in notification

About Contact Privacy policy Terms and conditions