• 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

How to break out of a foreach once a condition is met?

MISSING UPDATES FOR: MEDIA Drupal 9

Laravel passport auth token not working after moving to different server

error:14094410:SSL routines:ssl3_read_bytes:sslv3 alert handshake failure

Laravel Sanctum CSRF not authenticating

HTML + PHP + PHPMAILER

Valet, Xdebug after reboot Big Sur not working

PHP to search within txt file and echo the whole line

Converting array to string and then back in PHP

Insert multidimensional array to codeigniter cart

PHP array, move keys and values to new array, but mix it up

Unable to uninstall brew php from homebrew

XAMPP keeps showing Dashboard/Welcome Page instead of the Configuration Page

Log a user out of a website when they put their computer to sleep

PHP mail function is sending blank message body

About Contact Privacy policy Terms and conditions