Created
November 29, 2020 23:29
-
-
Save noritakaIzumi/4f99793930c1931d19affd871c8590b9 to your computer and use it in GitHub Desktop.
ローカル環境の時だけ自己署名証明書のサイトへの file_get_contents を通す
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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