• 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 get quarter for future date using Carbon?

Display specific shipping method if woocommerce product has specific acf field value

Laravel 4 Redirect::back() not going to previous page (refreshing current page)

How to validate tin and cst using PHP?

PHP and WebView - Cookie doesn't are the same

Wordpress add responsive srcset header image to theme

how to validate form data in codeigniter 4

SendGrid: Sending an email to multiple recipients without other emails being shown on the "to" field

Get sql.h error on MacOS 12 (Monterey) sqsrv and pdo_sqsrv drive installation

Laravel 5.1 how to use {{ old('') }} helper on blade file for radio inputs

PHP each() function replacement

How to change HTML structure inside WP <head>

Yoast SEO (WordPress Plugin) - Get plugin generated data manually

Why do I have invalid argument supply for foreach in Laravel for json response? [duplicate]

Apply filter array/return terms

About Contact Privacy policy Terms and conditions