• 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

Laravel: HTML in notification

add " ? " in url via htaccess RewriteRule

Lumen - Postgresql setup - Composer

PHP: remove filename from path

Required field only if another field has a value, must be empty otherwise

PHP AWS Cognito 'Error executing "SignUp" : ResourceNotFoundException : User pool client XXXX does not exist

Woocommerce redirect after add-to-cart error

backup files to google drive using PHP

How to get Laravel's CSRF Token from Another Website?

Backend cannot be reached after Typo3 login screen

How do I truncate a decimal in PHP?

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

How to change 'users' auth table and use another instead Laravel

Fatal error: Uncaught mysqli_sql_exception: Unknown database 'test' in ... (How do I fix that? Using PHP)

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

About Contact Privacy policy Terms and conditions