What is the difference between catching exceptions with and without a backslash in PHP?

When catching exceptions in PHP, using a backslash before the exception class name indicates that the exception should be caught from the global namespace. Without the backslash, PHP will look for the exception class within the current namespace first before falling back to the global namespace. This can lead to unexpected behavior if the exception class is not found in the current namespace.

// Catching exception without backslash
try {
    // Code that may throw an exception
} catch(Exception $e) {
    // Handle the exception
}

// Catching exception with backslash
try {
    // Code that may throw an exception
} catch(\Exception $e) {
    // Handle the exception
}