Is it possible to display the line number and script name where an error occurred in PHP?

Yes, it is possible to display the line number and script name where an error occurred in PHP by using the magic constants `__LINE__` and `__FILE__`. You can use these constants within an error handling function to output the line number and script name when an error occurs.

function customErrorHandler($errno, $errstr, $errfile, $errline) {
    echo "Error: $errstr in $errfile on line $errline";
}

set_error_handler("customErrorHandler");

// Trigger an error to test the custom error handler
echo $undefinedVariable;