• 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

PHP if in_array() how to get the key as well?

codeigniter 4 running error first time with xampp

How can i hide dt if dd got empty value

wp_remote_get() not passing authentication

could not find driver Debian SQL Server PHP

ConstraintViolationListInterface to Exception in Symfony

Lexik JWT authentication problem "Invalid credentials"

PHPExcel How to set conditional formatting to change cell background color based on cells values

How to get result of the formula on import xlsx with maatwebsite using Laravel? I get formula and not value of the formula

Laravel Livewire: jQuery not working in child component loaded via @if statement

How to get the ID of the link in another page in php

phpMyAdmin ERROR: mysqli_real_connect(): (HY000/1045): Access denied for user 'pma'@'localhost' (using password: NO)

get data-value with variable value

Laravel Database Strict Mode

Smarty: undefined extension class 'Smarty_Internal_Method_Get_Template_Vars'

About Contact Privacy policy Terms and conditions