Can you provide a practical example where try-catch blocks in PHP are more advantageous than manual error handling?

Try-catch blocks in PHP are more advantageous than manual error handling when dealing with functions or methods that may throw exceptions. By using try-catch blocks, you can easily catch and handle any exceptions that are thrown, preventing your script from crashing. This can help improve the overall stability and reliability of your code.

try {
    // Code that may throw an exception
    $result = someFunction();
} catch (Exception $e) {
    // Handle the exception
    echo 'An error occurred: ' . $e->getMessage();
}