Lỗi thời gian chạy trong PHP là gì?

Nếu ứng dụng Slim Framework của bạn gây ra lỗi Thời gian chạy PHP (chỉ dành cho PHP 7+), ứng dụng sẽ gọi trình xử lý Lỗi PHP của nó và trả về phản hồi

// Create Slim
$app = new \Slim\App();
// get the app's di-container
$c = $app->getContainer();
$c['phpErrorHandler'] = function ($c) {
    return function ($request, $response, $error) use ($c) {
        return $response->withStatus(500)
            ->withHeader('Content-Type', 'text/html')
            ->write('Something went wrong!');
    };
};
7 cho máy khách HTTP

Xin lưu ý rằng

// Create Slim
$app = new \Slim\App();
// get the app's di-container
$c = $app->getContainer();
$c['phpErrorHandler'] = function ($c) {
    return function ($request, $response, $error) use ($c) {
        return $response->withStatus(500)
            ->withHeader('Content-Type', 'text/html')
            ->write('Something went wrong!');
    };
};
8 và
// Create Slim
$app = new \Slim\App();
// get the app's di-container
$c = $app->getContainer();
$c['phpErrorHandler'] = function ($c) {
    return function ($request, $response, $error) use ($c) {
        return $response->withStatus(500)
            ->withHeader('Content-Type', 'text/html')
            ->write('Something went wrong!');
    };
};
9 không bị bắt theo mặc định. Nếu bạn muốn ứng dụng của mình hiển thị trang lỗi khi chúng xảy ra, bạn phải chạy đoạn mã sau trước khi ứng dụng khởi động. Trong hầu hết các trường hợp, điều đó có nghĩa là thêm nó vào đầu của
PHP Fatal error:  Uncaught Error: 
Call to undefined function diff() 
in /home/36db1ad4634ff7deb7f7347a4ac14d3a.php:12

Stack trace:
#0 {main}
  thrown in /home/36db1ad4634ff7deb7f7347a4ac14d3a.php on line 12
0

Bằng cách này, tất cả

// Create Slim
$app = new \Slim\App();
// get the app's di-container
$c = $app->getContainer();
$c['phpErrorHandler'] = function ($c) {
    return function ($request, $response, $error) use ($c) {
        return $response->withStatus(500)
            ->withHeader('Content-Type', 'text/html')
            ->write('Something went wrong!');
    };
};
8 và
// Create Slim
$app = new \Slim\App();
// get the app's di-container
$c = $app->getContainer();
$c['phpErrorHandler'] = function ($c) {
    return function ($request, $response, $error) use ($c) {
        return $response->withStatus(500)
            ->withHeader('Content-Type', 'text/html')
            ->write('Something went wrong!');
    };
};
9 sẽ được coi là
PHP Fatal error:  Uncaught Error: 
Call to undefined function diff() 
in /home/36db1ad4634ff7deb7f7347a4ac14d3a.php:12

Stack trace:
#0 {main}
  thrown in /home/36db1ad4634ff7deb7f7347a4ac14d3a.php on line 12
3 và như vậy sẽ kích hoạt các trình xử lý đã xác định

Trình xử lý lỗi PHP mặc định

Mỗi ứng dụng Slim Framework có trình xử lý Lỗi PHP mặc định. Trình xử lý này đặt trạng thái Phản hồi thành

PHP Fatal error:  Uncaught Error: 
Call to undefined function diff() 
in /home/36db1ad4634ff7deb7f7347a4ac14d3a.php:12

Stack trace:
#0 {main}
  thrown in /home/36db1ad4634ff7deb7f7347a4ac14d3a.php on line 12
4, nó đặt loại nội dung thành
// Create Slim
$app = new \Slim\App();
// get the app's di-container
$c = $app->getContainer();
$c['phpErrorHandler'] = function ($c) {
    return function ($request, $response, $error) use ($c) {
        return $response->withStatus(500)
            ->withHeader('Content-Type', 'text/html')
            ->write('Something went wrong!');
    };
};
0 và nó viết một lời giải thích đơn giản cho nội dung Phản hồi

Trình xử lý lỗi PHP tùy chỉnh

Trình xử lý lỗi PHP của ứng dụng Slim Framework là một dịch vụ Pimple. Bạn có thể thay thế trình xử lý Lỗi PHP của riêng mình bằng cách xác định phương thức xuất xưởng Pimple tùy chỉnh bằng bộ chứa ứng dụng

// Create Slim
$app = new \Slim\App();
// get the app's di-container
$c = $app->getContainer();
$c['phpErrorHandler'] = function ($c) {
    return function ($request, $response, $error) use ($c) {
        return $response->withStatus(500)
            ->withHeader('Content-Type', 'text/html')
            ->write('Something went wrong!');
    };
};

N. B Xem tài liệu Không tìm thấy để biết phương pháp tạo pre-slim bằng phiên bản mới của

// Create Slim
$app = new \Slim\App();
// get the app's di-container
$c = $app->getContainer();
$c['phpErrorHandler'] = function ($c) {
    return function ($request, $response, $error) use ($c) {
        return $response->withStatus(500)
            ->withHeader('Content-Type', 'text/html')
            ->write('Something went wrong!');
    };
};
1

Trong ví dụ này, chúng tôi xác định một nhà máy

// Create Slim
$app = new \Slim\App();
// get the app's di-container
$c = $app->getContainer();
$c['phpErrorHandler'] = function ($c) {
    return function ($request, $response, $error) use ($c) {
        return $response->withStatus(500)
            ->withHeader('Content-Type', 'text/html')
            ->write('Something went wrong!');
    };
};
2 mới trả về một giá trị có thể gọi được. Có thể gọi được trả về chấp nhận ba đối số

Lỗi là lỗi hoặc lỗi trong một chương trình. Nó có thể là một số loại. Lỗi có thể xảy ra do sai cú pháp hoặc sai logic. Đó là một loại lỗi hoặc tình trạng hiểu biết sai về mã

Có nhiều loại lỗi khác nhau trong PHP nhưng về cơ bản có bốn loại lỗi chính

  1. Lỗi phân tích cú pháp hoặc Lỗi cú pháp. Là loại lỗi do người lập trình thực hiện trong mã nguồn của chương trình. Lỗi cú pháp được bắt bởi trình biên dịch. Sau khi sửa lỗi cú pháp, trình biên dịch sẽ biên dịch mã và thực thi nó. Lỗi phân tích cú pháp có thể do dấu ngoặc kép không đóng, dấu ngoặc đơn bị thiếu hoặc thừa, dấu ngoặc nhọn không đóng, thiếu dấu chấm phẩy, v.v.
    Ví dụ.




    PHP Fatal error:  Uncaught Error: 
    Call to undefined function diff() 
    in /home/36db1ad4634ff7deb7f7347a4ac14d3a.php:12
    
    Stack trace:
    #0 {main}
      thrown in /home/36db1ad4634ff7deb7f7347a4ac14d3a.php on line 12
    
    5

    PHP Fatal error:  Uncaught Error: 
    Call to undefined function diff() 
    in /home/36db1ad4634ff7deb7f7347a4ac14d3a.php:12
    
    Stack trace:
    #0 {main}
      thrown in /home/36db1ad4634ff7deb7f7347a4ac14d3a.php on line 12
    
    6
    PHP Fatal error:  Uncaught Error: 
    Call to undefined function diff() 
    in /home/36db1ad4634ff7deb7f7347a4ac14d3a.php:12
    
    Stack trace:
    #0 {main}
      thrown in /home/36db1ad4634ff7deb7f7347a4ac14d3a.php on line 12
    
    7____58
    PHP Fatal error:  Uncaught Error: 
    Call to undefined function diff() 
    in /home/36db1ad4634ff7deb7f7347a4ac14d3a.php:12
    
    Stack trace:
    #0 {main}
      thrown in /home/36db1ad4634ff7deb7f7347a4ac14d3a.php on line 12
    
    9

    PHP Fatal error:  Uncaught Error: 
    Call to undefined function diff() 
    in /home/36db1ad4634ff7deb7f7347a4ac14d3a.php:12
    
    Stack trace:
    #0 {main}
      thrown in /home/36db1ad4634ff7deb7f7347a4ac14d3a.php on line 12
    
    0
    PHP Fatal error:  Uncaught Error: 
    Call to undefined function diff() 
    in /home/36db1ad4634ff7deb7f7347a4ac14d3a.php:12
    
    Stack trace:
    #0 {main}
      thrown in /home/36db1ad4634ff7deb7f7347a4ac14d3a.php on line 12
    
    1
    PHP Fatal error:  Uncaught Error: 
    Call to undefined function diff() 
    in /home/36db1ad4634ff7deb7f7347a4ac14d3a.php:12
    
    Stack trace:
    #0 {main}
      thrown in /home/36db1ad4634ff7deb7f7347a4ac14d3a.php on line 12
    
    9

    PHP Fatal error:  Uncaught Error: 
    Call to undefined function diff() 
    in /home/36db1ad4634ff7deb7f7347a4ac14d3a.php:12
    
    Stack trace:
    #0 {main}
      thrown in /home/36db1ad4634ff7deb7f7347a4ac14d3a.php on line 12
    
    3
    PHP Fatal error:  Uncaught Error: 
    Call to undefined function diff() 
    in /home/36db1ad4634ff7deb7f7347a4ac14d3a.php:12
    
    Stack trace:
    #0 {main}
      thrown in /home/36db1ad4634ff7deb7f7347a4ac14d3a.php on line 12
    
    6____59

    PHP Fatal error:  Uncaught Error: 
    Call to undefined function diff() 
    in /home/36db1ad4634ff7deb7f7347a4ac14d3a.php:12
    
    Stack trace:
    #0 {main}
      thrown in /home/36db1ad4634ff7deb7f7347a4ac14d3a.php on line 12
    
    3
    PHP Fatal error:  Uncaught Error: 
    Call to undefined function diff() 
    in /home/36db1ad4634ff7deb7f7347a4ac14d3a.php:12
    
    Stack trace:
    #0 {main}
      thrown in /home/36db1ad4634ff7deb7f7347a4ac14d3a.php on line 12
    
    7
    PHP Fatal error:  Uncaught Error: 
    Call to undefined function diff() 
    in /home/36db1ad4634ff7deb7f7347a4ac14d3a.php:12
    
    Stack trace:
    #0 {main}
      thrown in /home/36db1ad4634ff7deb7f7347a4ac14d3a.php on line 12
    
    9

    PHP Fatal error:  Uncaught Error: 
    Call to undefined function diff() 
    in /home/36db1ad4634ff7deb7f7347a4ac14d3a.php:12
    
    Stack trace:
    #0 {main}
      thrown in /home/36db1ad4634ff7deb7f7347a4ac14d3a.php on line 12
    
    9

    Lỗi

    // Create Slim
    $app = new \Slim\App();
    // get the app's di-container
    $c = $app->getContainer();
    $c['phpErrorHandler'] = function ($c) {
        return function ($request, $response, $error) use ($c) {
            return $response->withStatus(500)
                ->withHeader('Content-Type', 'text/html')
                ->write('Something went wrong!');
        };
    };
    
    1

    Giải trình. Chương trình trên thiếu dấu $ ở dòng 3 nên báo lỗi

  2. Lỗi nghiêm trọng. Đây là loại lỗi mà trình biên dịch PHP hiểu mã PHP nhưng nó nhận ra một chức năng không được khai báo. Điều này có nghĩa là chức năng được gọi mà không có định nghĩa của chức năng.
    Ví dụ.




    PHP Fatal error:  Uncaught Error: 
    Call to undefined function diff() 
    in /home/36db1ad4634ff7deb7f7347a4ac14d3a.php:12
    
    Stack trace:
    #0 {main}
      thrown in /home/36db1ad4634ff7deb7f7347a4ac14d3a.php on line 12
    
    5

    // Create Slim
    $app = new \Slim\App();
    // get the app's di-container
    $c = $app->getContainer();
    $c['phpErrorHandler'] = function ($c) {
        return function ($request, $response, $error) use ($c) {
            return $response->withStatus(500)
                ->withHeader('Content-Type', 'text/html')
                ->write('Something went wrong!');
        };
    };
    
    21

    // Create Slim
    $app = new \Slim\App();
    // get the app's di-container
    $c = $app->getContainer();
    $c['phpErrorHandler'] = function ($c) {
        return function ($request, $response, $error) use ($c) {
            return $response->withStatus(500)
                ->withHeader('Content-Type', 'text/html')
                ->write('Something went wrong!');
        };
    };
    
    22
    // Create Slim
    $app = new \Slim\App();
    // get the app's di-container
    $c = $app->getContainer();
    $c['phpErrorHandler'] = function ($c) {
        return function ($request, $response, $error) use ($c) {
            return $response->withStatus(500)
                ->withHeader('Content-Type', 'text/html')
                ->write('Something went wrong!');
        };
    };
    
    23____56____125
    PHP Fatal error:  Uncaught Error: 
    Call to undefined function diff() 
    in /home/36db1ad4634ff7deb7f7347a4ac14d3a.php:12
    
    Stack trace:
    #0 {main}
      thrown in /home/36db1ad4634ff7deb7f7347a4ac14d3a.php on line 12
    
    7
    // Create Slim
    $app = new \Slim\App();
    // get the app's di-container
    $c = $app->getContainer();
    $c['phpErrorHandler'] = function ($c) {
        return function ($request, $response, $error) use ($c) {
            return $response->withStatus(500)
                ->withHeader('Content-Type', 'text/html')
                ->write('Something went wrong!');
        };
    };
    
    27

    // Create Slim
    $app = new \Slim\App();
    // get the app's di-container
    $c = $app->getContainer();
    $c['phpErrorHandler'] = function ($c) {
        return function ($request, $response, $error) use ($c) {
            return $response->withStatus(500)
                ->withHeader('Content-Type', 'text/html')
                ->write('Something went wrong!');
        };
    };
    
    28

    // Create Slim
    $app = new \Slim\App();
    // get the app's di-container
    $c = $app->getContainer();
    $c['phpErrorHandler'] = function ($c) {
        return function ($request, $response, $error) use ($c) {
            return $response->withStatus(500)
                ->withHeader('Content-Type', 'text/html')
                ->write('Something went wrong!');
        };
    };
    
    29
    // Create Slim
    $app = new \Slim\App();
    // get the app's di-container
    $c = $app->getContainer();
    $c['phpErrorHandler'] = function ($c) {
        return function ($request, $response, $error) use ($c) {
            return $response->withStatus(500)
                ->withHeader('Content-Type', 'text/html')
                ->write('Something went wrong!');
        };
    };
    
    00
    PHP Fatal error:  Uncaught Error: 
    Call to undefined function diff() 
    in /home/36db1ad4634ff7deb7f7347a4ac14d3a.php:12
    
    Stack trace:
    #0 {main}
      thrown in /home/36db1ad4634ff7deb7f7347a4ac14d3a.php on line 12
    
    7
    PHP Fatal error:  Uncaught Error: 
    Call to undefined function diff() 
    in /home/36db1ad4634ff7deb7f7347a4ac14d3a.php:12
    
    Stack trace:
    #0 {main}
      thrown in /home/36db1ad4634ff7deb7f7347a4ac14d3a.php on line 12
    
    6
    // Create Slim
    $app = new \Slim\App();
    // get the app's di-container
    $c = $app->getContainer();
    $c['phpErrorHandler'] = function ($c) {
        return function ($request, $response, $error) use ($c) {
            return $response->withStatus(500)
                ->withHeader('Content-Type', 'text/html')
                ->write('Something went wrong!');
        };
    };
    
    03
    PHP Fatal error:  Uncaught Error: 
    Call to undefined function diff() 
    in /home/36db1ad4634ff7deb7f7347a4ac14d3a.php:12
    
    Stack trace:
    #0 {main}
      thrown in /home/36db1ad4634ff7deb7f7347a4ac14d3a.php on line 12
    
    7
    PHP Fatal error:  Uncaught Error: 
    Call to undefined function diff() 
    in /home/36db1ad4634ff7deb7f7347a4ac14d3a.php:12
    
    Stack trace:
    #0 {main}
      thrown in /home/36db1ad4634ff7deb7f7347a4ac14d3a.php on line 12
    
    9

    // Create Slim
    $app = new \Slim\App();
    // get the app's di-container
    $c = $app->getContainer();
    $c['phpErrorHandler'] = function ($c) {
        return function ($request, $response, $error) use ($c) {
            return $response->withStatus(500)
                ->withHeader('Content-Type', 'text/html')
                ->write('Something went wrong!');
        };
    };
    
    29
    PHP Fatal error:  Uncaught Error: 
    Call to undefined function diff() 
    in /home/36db1ad4634ff7deb7f7347a4ac14d3a.php:12
    
    Stack trace:
    #0 {main}
      thrown in /home/36db1ad4634ff7deb7f7347a4ac14d3a.php on line 12
    
    3
    // Create Slim
    $app = new \Slim\App();
    // get the app's di-container
    $c = $app->getContainer();
    $c['phpErrorHandler'] = function ($c) {
        return function ($request, $response, $error) use ($c) {
            return $response->withStatus(500)
                ->withHeader('Content-Type', 'text/html')
                ->write('Something went wrong!');
        };
    };
    
    08
    // Create Slim
    $app = new \Slim\App();
    // get the app's di-container
    $c = $app->getContainer();
    $c['phpErrorHandler'] = function ($c) {
        return function ($request, $response, $error) use ($c) {
            return $response->withStatus(500)
                ->withHeader('Content-Type', 'text/html')
                ->write('Something went wrong!');
        };
    };
    
    09
    // Create Slim
    $app = new \Slim\App();
    // get the app's di-container
    $c = $app->getContainer();
    $c['phpErrorHandler'] = function ($c) {
        return function ($request, $response, $error) use ($c) {
            return $response->withStatus(500)
                ->withHeader('Content-Type', 'text/html')
                ->write('Something went wrong!');
        };
    };
    
    00
    PHP Fatal error:  Uncaught Error: 
    Call to undefined function diff() 
    in /home/36db1ad4634ff7deb7f7347a4ac14d3a.php:12
    
    Stack trace:
    #0 {main}
      thrown in /home/36db1ad4634ff7deb7f7347a4ac14d3a.php on line 12
    
    9

    // Create Slim
    $app = new \Slim\App();
    // get the app's di-container
    $c = $app->getContainer();
    $c['phpErrorHandler'] = function ($c) {
        return function ($request, $response, $error) use ($c) {
            return $response->withStatus(500)
                ->withHeader('Content-Type', 'text/html')
                ->write('Something went wrong!');
        };
    };
    
    82

    PHP Fatal error:  Uncaught Error: 
    Call to undefined function diff() 
    in /home/36db1ad4634ff7deb7f7347a4ac14d3a.php:12
    
    Stack trace:
    #0 {main}
      thrown in /home/36db1ad4634ff7deb7f7347a4ac14d3a.php on line 12
    
    6
    // Create Slim
    $app = new \Slim\App();
    // get the app's di-container
    $c = $app->getContainer();
    $c['phpErrorHandler'] = function ($c) {
        return function ($request, $response, $error) use ($c) {
            return $response->withStatus(500)
                ->withHeader('Content-Type', 'text/html')
                ->write('Something went wrong!');
        };
    };
    
    84

    PHP Fatal error:  Uncaught Error: 
    Call to undefined function diff() 
    in /home/36db1ad4634ff7deb7f7347a4ac14d3a.php:12
    
    Stack trace:
    #0 {main}
      thrown in /home/36db1ad4634ff7deb7f7347a4ac14d3a.php on line 12
    
    7
    // Create Slim
    $app = new \Slim\App();
    // get the app's di-container
    $c = $app->getContainer();
    $c['phpErrorHandler'] = function ($c) {
        return function ($request, $response, $error) use ($c) {
            return $response->withStatus(500)
                ->withHeader('Content-Type', 'text/html')
                ->write('Something went wrong!');
        };
    };
    
    86

    // Create Slim
    $app = new \Slim\App();
    // get the app's di-container
    $c = $app->getContainer();
    $c['phpErrorHandler'] = function ($c) {
        return function ($request, $response, $error) use ($c) {
            return $response->withStatus(500)
                ->withHeader('Content-Type', 'text/html')
                ->write('Something went wrong!');
        };
    };
    
    23
    PHP Fatal error:  Uncaught Error: 
    Call to undefined function diff() 
    in /home/36db1ad4634ff7deb7f7347a4ac14d3a.php:12
    
    Stack trace:
    #0 {main}
      thrown in /home/36db1ad4634ff7deb7f7347a4ac14d3a.php on line 12
    
    6
    // Create Slim
    $app = new \Slim\App();
    // get the app's di-container
    $c = $app->getContainer();
    $c['phpErrorHandler'] = function ($c) {
        return function ($request, $response, $error) use ($c) {
            return $response->withStatus(500)
                ->withHeader('Content-Type', 'text/html')
                ->write('Something went wrong!');
        };
    };
    
    25
    PHP Fatal error:  Uncaught Error: 
    Call to undefined function diff() 
    in /home/36db1ad4634ff7deb7f7347a4ac14d3a.php:12
    
    Stack trace:
    #0 {main}
      thrown in /home/36db1ad4634ff7deb7f7347a4ac14d3a.php on line 12
    
    7
    PHP Fatal error:  Uncaught Error: 
    Call to undefined function diff() 
    in /home/36db1ad4634ff7deb7f7347a4ac14d3a.php:12
    
    Stack trace:
    #0 {main}
      thrown in /home/36db1ad4634ff7deb7f7347a4ac14d3a.php on line 12
    
    51

    // Create Slim
    $app = new \Slim\App();
    // get the app's di-container
    $c = $app->getContainer();
    $c['phpErrorHandler'] = function ($c) {
        return function ($request, $response, $error) use ($c) {
            return $response->withStatus(500)
                ->withHeader('Content-Type', 'text/html')
                ->write('Something went wrong!');
        };
    };
    
    21

    PHP Fatal error:  Uncaught Error: 
    Call to undefined function diff() 
    in /home/36db1ad4634ff7deb7f7347a4ac14d3a.php:12
    
    Stack trace:
    #0 {main}
      thrown in /home/36db1ad4634ff7deb7f7347a4ac14d3a.php on line 12
    
    53
    PHP Fatal error:  Uncaught Error: 
    Call to undefined function diff() 
    in /home/36db1ad4634ff7deb7f7347a4ac14d3a.php:12
    
    Stack trace:
    #0 {main}
      thrown in /home/36db1ad4634ff7deb7f7347a4ac14d3a.php on line 12
    
    6____125____57
    PHP Fatal error:  Uncaught Error: 
    Call to undefined function diff() 
    in /home/36db1ad4634ff7deb7f7347a4ac14d3a.php:12
    
    Stack trace:
    #0 {main}
      thrown in /home/36db1ad4634ff7deb7f7347a4ac14d3a.php on line 12
    
    51

    PHP Fatal error:  Uncaught Error: 
    Call to undefined function diff() 
    in /home/36db1ad4634ff7deb7f7347a4ac14d3a.php:12
    
    Stack trace:
    #0 {main}
      thrown in /home/36db1ad4634ff7deb7f7347a4ac14d3a.php on line 12
    
    9

    Lỗi

    PHP Fatal error:  Uncaught Error: 
    Call to undefined function diff() 
    in /home/36db1ad4634ff7deb7f7347a4ac14d3a.php:12
    
    Stack trace:
    #0 {main}
      thrown in /home/36db1ad4634ff7deb7f7347a4ac14d3a.php on line 12
    

    Giải trình. Ở dòng 12, hàm được gọi nhưng không có định nghĩa hàm. Vì vậy, nó đưa ra lỗi

  3. Lỗi Cảnh báo. Lý do chính của lỗi cảnh báo bao gồm một tệp bị thiếu. Điều này có nghĩa là hàm PHP gọi tệp bị thiếu.
    Ví dụ.




    PHP Fatal error:  Uncaught Error: 
    Call to undefined function diff() 
    in /home/36db1ad4634ff7deb7f7347a4ac14d3a.php:12
    
    Stack trace:
    #0 {main}
      thrown in /home/36db1ad4634ff7deb7f7347a4ac14d3a.php on line 12
    
    59

    // Create Slim
    $app = new \Slim\App();
    // get the app's di-container
    $c = $app->getContainer();
    $c['phpErrorHandler'] = function ($c) {
        return function ($request, $response, $error) use ($c) {
            return $response->withStatus(500)
                ->withHeader('Content-Type', 'text/html')
                ->write('Something went wrong!');
        };
    };
    
    21

    PHP Fatal error:  Uncaught Error: 
    Call to undefined function diff() 
    in /home/36db1ad4634ff7deb7f7347a4ac14d3a.php:12
    
    Stack trace:
    #0 {main}
      thrown in /home/36db1ad4634ff7deb7f7347a4ac14d3a.php on line 12
    
    6
    PHP Fatal error:  Uncaught Error: 
    Call to undefined function diff() 
    in /home/36db1ad4634ff7deb7f7347a4ac14d3a.php:12
    
    Stack trace:
    #0 {main}
      thrown in /home/36db1ad4634ff7deb7f7347a4ac14d3a.php on line 12
    
    7____563____59

    // Create Slim
    $app = new \Slim\App();
    // get the app's di-container
    $c = $app->getContainer();
    $c['phpErrorHandler'] = function ($c) {
        return function ($request, $response, $error) use ($c) {
            return $response->withStatus(500)
                ->withHeader('Content-Type', 'text/html')
                ->write('Something went wrong!');
        };
    };
    
    21

    PHP Fatal error:  Uncaught Error: 
    Call to undefined function diff() 
    in /home/36db1ad4634ff7deb7f7347a4ac14d3a.php:12
    
    Stack trace:
    #0 {main}
      thrown in /home/36db1ad4634ff7deb7f7347a4ac14d3a.php on line 12
    
    66
    PHP Fatal error:  Uncaught Error: 
    Call to undefined function diff() 
    in /home/36db1ad4634ff7deb7f7347a4ac14d3a.php:12
    
    Stack trace:
    #0 {main}
      thrown in /home/36db1ad4634ff7deb7f7347a4ac14d3a.php on line 12
    
    67____568
    PHP Fatal error:  Uncaught Error: 
    Call to undefined function diff() 
    in /home/36db1ad4634ff7deb7f7347a4ac14d3a.php:12
    
    Stack trace:
    #0 {main}
      thrown in /home/36db1ad4634ff7deb7f7347a4ac14d3a.php on line 12
    
    51

    // Create Slim
    $app = new \Slim\App();
    // get the app's di-container
    $c = $app->getContainer();
    $c['phpErrorHandler'] = function ($c) {
        return function ($request, $response, $error) use ($c) {
            return $response->withStatus(500)
                ->withHeader('Content-Type', 'text/html')
                ->write('Something went wrong!');
        };
    };
    
    21

    PHP Fatal error:  Uncaught Error: 
    Call to undefined function diff() 
    in /home/36db1ad4634ff7deb7f7347a4ac14d3a.php:12
    
    Stack trace:
    #0 {main}
      thrown in /home/36db1ad4634ff7deb7f7347a4ac14d3a.php on line 12
    
    3
    PHP Fatal error:  Uncaught Error: 
    Call to undefined function diff() 
    in /home/36db1ad4634ff7deb7f7347a4ac14d3a.php:12
    
    Stack trace:
    #0 {main}
      thrown in /home/36db1ad4634ff7deb7f7347a4ac14d3a.php on line 12
    
    6
    // Create Slim
    $app = new \Slim\App();
    // get the app's di-container
    $c = $app->getContainer();
    $c['phpErrorHandler'] = function ($c) {
        return function ($request, $response, $error) use ($c) {
            return $response->withStatus(500)
                ->withHeader('Content-Type', 'text/html')
                ->write('Something went wrong!');
        };
    };
    
    09____574
    PHP Fatal error:  Uncaught Error: 
    Call to undefined function diff() 
    in /home/36db1ad4634ff7deb7f7347a4ac14d3a.php:12
    
    Stack trace:
    #0 {main}
      thrown in /home/36db1ad4634ff7deb7f7347a4ac14d3a.php on line 12
    
    9

    PHP Fatal error:  Uncaught Error: 
    Call to undefined function diff() 
    in /home/36db1ad4634ff7deb7f7347a4ac14d3a.php:12
    
    Stack trace:
    #0 {main}
      thrown in /home/36db1ad4634ff7deb7f7347a4ac14d3a.php on line 12
    
    9

    Lỗi

    // Create Slim
    $app = new \Slim\App();
    // get the app's di-container
    $c = $app->getContainer();
    $c['phpErrorHandler'] = function ($c) {
        return function ($request, $response, $error) use ($c) {
            return $response->withStatus(500)
                ->withHeader('Content-Type', 'text/html')
                ->write('Something went wrong!');
        };
    };
    
    2

    Giải trình. Chương trình này gọi một tệp không xác định gfg. php không có sẵn. Vì vậy, nó tạo ra lỗi

    lỗi thời gian chạy giải thích là gì?

    Lỗi thời gian chạy xảy ra khi chương trình đúng về mặt cú pháp nhưng có vấn đề chỉ được phát hiện trong quá trình thực thi chương trình . Trình biên dịch Java không thể phát hiện các sự cố này tại thời điểm biên dịch và chỉ được phát hiện bởi Máy ảo Java (JVM) khi ứng dụng đang chạy.

    Ngoại lệ thời gian chạy trong PHP là gì?

    RuntimeException là một ngoại lệ cũng có thể xảy ra trong mã được viết và định cấu hình 'hoàn hảo' . Một ngoại lệ như vậy có thể do đầu vào từ người dùng cuối gây ra hoặc lỗi trong (giao tiếp với) một hệ thống bên ngoài. Khi một RuntimeException được ném ra, nó sẽ không yêu cầu sửa lỗi trong mã.

    một số lỗi thời gian chạy ví dụ là gì?

    Dưới đây là một số ví dụ về các lỗi thời gian chạy phổ biến mà bạn chắc chắn sẽ gặp phải. Tên biến và hàm sai chính tả hoặc viết hoa sai chính tả . Nỗ lực thực hiện các phép toán (chẳng hạn như phép toán) trên dữ liệu không đúng loại (ví dụ:. cố gắng trừ hai biến chứa giá trị chuỗi)

    Ba loại lỗi trong PHP là gì?

    4 Các loại lỗi khác nhau trong PHP .
    Lỗi cảnh báo
    thông báo lỗi
    Lỗi phân tích cú pháp (Cú pháp)
    Lỗi nghiêm trọng