• 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

Dropdown with current value from Mysql

Create tags in laravel post publishing

php file upload scanning using clamav, permissions on /tmp/

Convert PHP array into HTML tag attributes separated by spaces

How can I convert from a{a{} b{}} to a[a[],b[]] using php preg_match?

Not able to access model in the controller mautic

phpseclib 2.0 can not use Composer to create autoload

wordpress function breaks wp-admin

Android Volley getParams() method not getting called for JsonObjectRequest

Getting error: CodeIgniterDatabaseBaseResult::getResult in CodeIgniter

Fetch files from next cloud storage and display in Laravel website

Statement that checks whether a URL contains a particular path?

virtctl works when executed via command line but not from php exec()

Converting IPv6 to IPv4 address in PHP

add " ? " in url via htaccess RewriteRule

About Contact Privacy policy Terms and conditions