• 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

add " ? " in url via htaccess RewriteRule

Creating command to backup MySql database in Laravel

How to create laravel storage symbolic link for production or sub domain system?

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

"Mixed content blocked" when running an HTTP AJAX operation in an HTTPS page

Calculating Median of an array in PHP

php script to delete files older than 24 hrs, deletes all files

Send POST data via raw JSON with Postman

Unable to create lockable file - Laravel 8 & PHP 8

How do I call a php file with axios?

How to change HTML structure inside WP <head>

Magento 2 - Controller returning blank page

MongoDB Duplicate Documents even after adding unique key

Reading input in php from terminal

how to upload binary image to sql server using php laravel

About Contact Privacy policy Terms and conditions