Reputation: 4503
I'm currently building a web crawler but to start I would like to test it on my shared webhosting, obviously they do not allow set_time_limit
so I can't make sure the script keeps running for longer than 30 seconds.
What would be the best way to start the PHP script the next time where it timed out before? I was thinking about saving the last crawled URL in a file but are there any other options?
Upvotes: 1
Views: 208
Reputation: 69
Edit: ScallioXTX is right, you can't use variables as a goto
label. You could get around that with a very large if
statement, but at this point I'd say it's best to not use goto
at all. Here is an alternative method:
<?php
// Load label number from database or text file into $label_num
if($label_num <= 1) {
// Do stuff
}
if($label_num <= 2) {
// Do more stuff
}
// ...
?>
Old (incorrect) method:
You can of course use goto
: https://www.php.net/goto
I would only use this as a temporary measure until you get better hosting.
Here's what I would do:
count1:
, count2:
, etc.)Example:
<?php
// Load label number from database or text file into $label_num
if($label_num) {
goto $label_num;
}
count1:
// Do stuff
count2:
// Do more stuff
// ...
?>
Upvotes: 1