• 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

insert multiple rows in a saveall in cakephp

Exception thrown during the rendering of a template("Parameter "id" for route "url" must match "[^/]++" ("" given) to generate a corresponding URL.")

PHP: How to solve ob_start() in combination imagepng() issue?

Array to string conversion

Laravel Database Strict Mode

Laravel Schedule not sending email

php retrieve specific data onclick from database in a list format

Why "Class 'GuzzleHttpClient' not found" even after Installing it in Laravel?

Send Outlook 2010 email using PHP

how to hide previous markers when new markers added in google map javascript api

I can't delete my image when it is liked because of the foreign key in mysql

Laravel s3 upload file with metadata using pre-signed url

Return multiple values from a function using mysqli_fetch_assoc [closed]

PHP Discord OAUTH2 code sample not working

Add customer email and phone in "Order" column to admin orders list on Woocommerce

About Contact Privacy policy Terms and conditions