• 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

file_put_content...fail to open stream:Permission denied in Laravel 5

Undefined variable in Laravel 8 project (php 7.4)

Extract string between first whitespace and last whitespace in php

Send POST data via raw JSON with Postman

Custom post type single page not working

How to redirect to another page and call a Function there on Angular ng-click

Make Shipping Method fields Mandatory on Woocommerce checkout page

Group data in a multidimensional array based on two columns

php: command not found Command PhaseScriptExecution failed with a nonzero exit code

How do I truncate a decimal in PHP?

Check if a string contain multiple specific words

How to create a cookie to store the timestamp of when a page is first loaded with php

PHP: Print caught exception like Xdebug

OAuth2 Token PHP

Laravel whole batch is cancelled if one Job fails

About Contact Privacy policy Terms and conditions