Answer the question
In order to leave comments, you need to log in
How to check file_get_contents in yii2?
in Yii2 I take data via file_get_contents from a remote page.
If the server is not available or the link is invalid, then yii2 gives an error:
PHP Warning 'yii\base\ErrorException' with message 'file_get_contents(): failed to open stream: Connection refused'
$context = stream_context_create(array(
'http' => array(
'header' => "Authorization: Basic " . base64_encode("$username:$password")
)
));
$data = file_get_contents($url, false, $context);
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question