• 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

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

Multiple order by in WooCommerce

How to get unique slug to same post-title for other time too?

Converting IPv6 to IPv4 address in PHP

oauth-private.key does not exist or is not readable

Docker & Laravel : configure: error: Package requirements (oniguruma) were not met

How to Display Data in Yajra Datatables Laravel 7?

PHP Get value from JSON [duplicate]

PHPS source file - 403 Forbidden You don't have permission to access this resource

Handle error for duplicate entries - PHP/MySQL

advanced custom fields wordpress custom class

Laravel Mix Uncaught ReferenceError: $ is not defined

Sum array values of a column within each column of an array with 3 levels

Php - Sum up the numbers in an array one by one

Yii2 redirecting to previous page after login

About Contact Privacy policy Terms and conditions