Skip to content

Instantly share code, notes, and snippets.

@noritakaIzumi
Created November 29, 2020 23:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save noritakaIzumi/4f99793930c1931d19affd871c8590b9 to your computer and use it in GitHub Desktop.
Save noritakaIzumi/4f99793930c1931d19affd871c8590b9 to your computer and use it in GitHub Desktop.
ローカル環境の時だけ自己署名証明書のサイトへの file_get_contents を通す
<?php
$environment = 'local'; // prod, stg, local, etc...
function fileGetContents(String $url)
{
global $environment;
if ($environment == 'local') {
$options = array(
'ssl' => array(
'verify_peer' => false,
'verify_peer_name' => false,
)
);
return file_get_contents($url, false, stream_context_create($options));
}
return file_get_contents($url);
}
echo fileGetContents("https://google.co.jp");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment