• 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 convert time from one timezone to another in PHP

How do I set the maximum php memory limit

How to Display Data in Yajra Datatables Laravel 7?

wordpress : How to specify the cause "This site can’t be reached"

How should I get started using PHPUnit as a testing framework for a bunch of functions and classes I have already made?

Last order would be re-order in wooCommerce. How is it possible?

How to install php yaml on CentOs?

PHP Imap , php 7.4.3 on mac osx catalina

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

PHP array stringify

Call to undefined function openssl_decrypt

php echo remove slashes from url [duplicate]

Store multiple fields in JSON column (Nova CMS)

dompdf and img tag, image wont show

selected value from the listbox in php

About Contact Privacy policy Terms and conditions