• 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

Elastic Beanstalk with Laravel Envoy

How to create a individual template for page or post in custom plugin?

run a query using EXECUTE BLOCK to prepair a column for an unique-Index

carbon generated datetime not stored correctly into the database

WordPress ACFNotice: get_field() - We've detected one or more calls to retrieve ACF field values before ACF has been initialized

enable Apache http Authorization header

Converting array to string and then back in PHP

How to change HTML structure inside WP <head>

generate an Excel file using PHP

Laravel Mixing of GROUP columns (MIN(),MAX(),COUNT(),...) on a sub query with "ROW_NUMBER() OVER PARTITION"

How to Display Data in Yajra Datatables Laravel 7?

Which is faster php date functions or carbon?

How do I do HTTP basic authentication using Guzzle?

Yii2 redirecting to previous page after login

WooCommerce - unset "<product> removed notice…" on cart page

About Contact Privacy policy Terms and conditions