• 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

Only on Firefox "Loading failed for the <script> with source"

How do I pass the dynamic output of a php variable or php function to a CSS variable?

Display the default discounted price and percentage on Woocommerce products

Confirm Leave on External Links in Wordpress

Doctrine ORM: Excluding Records Based on Values of Nested Relationships

Laravel: HTML in notification

How to remove index.php and index from the URL using htaccess | PHP

MySQL - Connection failed: No route to host

How to create custom authentication in laravel 8?

PHP: PDO + CSV export not downloading (headers issue?)

Transfer data between JavaScript and PHP through JSON

WooCommerce Additional Information - if empty, hide

Composer Warning: openssl extension is missing. How to enable in WAMP

Sort multidimensional array by column value within a column

PHP Imap , php 7.4.3 on mac osx catalina

About Contact Privacy policy Terms and conditions