PHP | How to set time limit for GET Request?

234
May 06, 2018, at 11:21 PM

Basically I send a GET request with a proxy,

And if the proxy dies so the page gets stuck and continues to load for a long time.

Is there a way to prevent it? And put a restriction of 5 seconds

set_time_limit(5) not working for some reason

<?php
set_time_limit(5);
//error_reporting(0);
$opts = array(
'http'=>array(
'method'=>"GET",
'proxy'=>"$proxy",
'header'=>"User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:51.0) Gecko/20100101 Firefox/51.0"
));
$context = stream_context_create($opts);
$url = "http://website.com/page.php";
$data = file_get_contents($url, false, $context);
echo $data;
?>
Rent Charter Buses Company
READ ALSO
Using php Reflection API to make dynamic getters and setters

Using php Reflection API to make dynamic getters and setters

I have some classes that do have a lot of properties!

159
Converting HTML to XML based on Its Semantics Using PHP

Converting HTML to XML based on Its Semantics Using PHP

In many cases an HTML file like this:

162
What can be the regex expression for the number starting with either 0 or 9 and consisting of exactly 9 or 10 digits? [on hold]

What can be the regex expression for the number starting with either 0 or 9 and consisting of exactly 9 or 10 digits? [on hold]

I have tried the regex expression of the following condition for both HTML form validation as well as server side validation in Laravel but it doesn't work: The number should start with either 0 or 9 and the number should be exactly 9 or 10 digits

136
How to embed php in twig

How to embed php in twig

I have a do_shortcut and I need to embed it in a twig templateI tried by coping the code in a php file my-code

264