S
S
sarkisssik2016-11-02 20:47:14
PHP
sarkisssik, 2016-11-02 20:47:14

500th file_get_contents response. How to decide?

Hello. I can not understand the cause of the problem: I write

file_get_contents(" http://non-existent.ru/ ");

and get 500 error (Internal Server Error).
If the url exists, then no error occurs. Where to dig?
On the other server, everything is fine and the error is knocked out as standard
Warning: file_get_contents( http://defunct.ru/): failed to open stream: HTTP request failed! in /var/www/user/data/www/dsdsdsds/_test.php on line 5

Answer the question

In order to leave comments, you need to log in

9 answer(s)
D
dev400, 2016-11-02
@dev400

Enable error reporting?

A
Artem Spiridonov, 2016-11-02
@customtema

Check what exists?

S
sim3x, 2016-11-02
@sim3x

php.net/manual/en/language.exceptions.php

I
Igor, 2016-11-03
@Kraky

Try like this.

$options = [
    'ignore_errors' => true
];
$context = stream_context_create($options);
$file = file_get_contents('http://someurl.com', false, $context);

L
littlekan, 2022-03-10
@littlekan

Hello!
Can't handle Internal Server Error.
I get this:
stream_context_create(): options should have the form ["wrappername"]["optionname"] = $value

A
Artem, 2017-01-13
Georgy Voronko

$('#test1, #test2, #nature_test1, #nature_test2, #animals_test').hide();

R
Rsa97, 2017-01-13
@Rsa97

$('.what-i-need-hide').hide()

K
kpa6uu, 2017-01-13
@kpa6uu

If your ID`s are strictly in order, as in the example, then loop through the interval from and to. If not, form an array of elements to hide / open, passing through it in the future.
This will shorten the code.

R
RomanKudlatov, 2018-08-18
@RomanKudlatov

But you can’t apply one class to all of them with handles, hide by class and open by id? If not, why not?)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question