0% found this document useful (0 votes)
22 views

Error Handling:: "En" "UTF-8" "Viewport" "Width Device-Width, Initial-Scale 1.0"

Error handling in PHP can be done by setting a custom error handler function using set_error_handler(). The function will handle different error levels and messages, displaying the error, file, and line. Common errors like undefined variables, invalid database connections, and undefined functions can then trigger the custom error handler.

Uploaded by

anam rani
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
22 views

Error Handling:: "En" "UTF-8" "Viewport" "Width Device-Width, Initial-Scale 1.0"

Error handling in PHP can be done by setting a custom error handler function using set_error_handler(). The function will handle different error levels and messages, displaying the error, file, and line. Common errors like undefined variables, invalid database connections, and undefined functions can then trigger the custom error handler.

Uploaded by

anam rani
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Error Handling:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>OOP</title>
    <style>
    body{
        height:100%;
        background:linear-gradient(to right,#67f9c2 0%, #878787 100%);
        color:#000;
        display:flex;
        justify-content:center;
    margin-top:10%;
    font-size:2rem;
    
    }
    </style>
</head>
<body>
<?php

function my_handler($error_level,$error_message,$error_file,$error_line,
$error_context)

      echo "Error :".$error_level,$error_message,$error_file;

      echo "<br/>";

set_error_handler('my_handler');

// error_reporting(E_ALL); 

// echo $temp;

// $r= fopen("ac.txt","r");
// test();

$db=@mysqli_connect(a,$b,$c);

if(!$db){

    trigger_error('database connection failed', E_USER_WARNING);

echo "<br><br>Hello Sir I've Completed The Error Handling Concept";

?>
      
</body>
</html>

OutPut

You might also like