I have a line in my PHP code that looks like this (it calls a function):
$objTest->joinServer($servers[array_rand($servers)]);
However, sometimes, the function/line throws back an error that continues in an infinite loop. How can I detect if this line throws back an error, and so something else instead?
Currently, I think that I may need to do something like this, but I have no idea how to implement it correctly:
$conn = $objTest->joinServer($servers[array_rand($servers)]);
if($conn has some error) {
// Do this
} else {
// No error so excute line
$objTest->joinServer($servers[array_rand($servers)]);
}