Skip to content

Instantly share code, notes, and snippets.

@tdebatty
tdebatty / file_get_contents.php
Last active October 27, 2022 12:10
file_get_contents with proxy support
<?php
$context = array();
$proxy = getenv("http_proxy");
if ($proxy !== null) {
$context['http'] = array(
'proxy' => str_replace("http", "tcp", $proxy),
'request_fulluri' => true
);
}
@troutacular
troutacular / is_localhost
Created May 30, 2015 00:02
PHP - Check if localhost
// Check if we are in a local environment
function is_localhost() {
// set the array for testing the local environment
$whitelist = array( '127.0.0.1', '::1' );
// check if the server is in the array
if ( in_array( $_SERVER['REMOTE_ADDR'], $whitelist ) ) {