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
- 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
2PHP 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
3PHP 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____45PHP 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
6PHP 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
0PHP 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
1PHP 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
6PHP 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
3PHP 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
3PHP 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
6PHP 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
3PHP 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
7PHP 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
6PHP 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
9Lỗi
PHP Parse error: syntax error, unexpected '=' in /home/18cb2875ac563160a6120819bab084c8.php on line 3
Giải trình. Chương trình trên thiếu dấu $ ở dòng 3 nên báo lỗi
- 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
2PHP Warning: include[gfg.php]: failed to open stream: No such file or directory in /home/aed0ed3b35fece41022f332aba5c9b45.php on line 5 PHP Warning: include[]: Failed opening 'gfg.php' for inclusion [include_path='.:/usr/share/php'] in /home/aed0ed3b35fece41022f332aba5c9b45.php on line 5
1PHP Warning: include[gfg.php]: failed to open stream: No such file or directory in /home/aed0ed3b35fece41022f332aba5c9b45.php on line 5 PHP Warning: include[]: Failed opening 'gfg.php' for inclusion [include_path='.:/usr/share/php'] in /home/aed0ed3b35fece41022f332aba5c9b45.php on line 5
2PHP Warning: include[gfg.php]: failed to open stream: No such file or directory in /home/aed0ed3b35fece41022f332aba5c9b45.php on line 5 PHP Warning: include[]: Failed opening 'gfg.php' for inclusion [include_path='.:/usr/share/php'] in /home/aed0ed3b35fece41022f332aba5c9b45.php on line 5
3PHP 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
3PHP Warning: include[gfg.php]: failed to open stream: No such file or directory in /home/aed0ed3b35fece41022f332aba5c9b45.php on line 5 PHP Warning: include[]: Failed opening 'gfg.php' for inclusion [include_path='.:/usr/share/php'] in /home/aed0ed3b35fece41022f332aba5c9b45.php on line 5
5PHP 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
7PHP Warning: include[gfg.php]: failed to open stream: No such file or directory in /home/aed0ed3b35fece41022f332aba5c9b45.php on line 5 PHP Warning: include[]: Failed opening 'gfg.php' for inclusion [include_path='.:/usr/share/php'] in /home/aed0ed3b35fece41022f332aba5c9b45.php on line 5
7PHP Warning: include[gfg.php]: failed to open stream: No such file or directory in /home/aed0ed3b35fece41022f332aba5c9b45.php on line 5 PHP Warning: include[]: Failed opening 'gfg.php' for inclusion [include_path='.:/usr/share/php'] in /home/aed0ed3b35fece41022f332aba5c9b45.php on line 5
8PHP Warning: include[gfg.php]: failed to open stream: No such file or directory in /home/aed0ed3b35fece41022f332aba5c9b45.php on line 5 PHP Warning: include[]: Failed opening 'gfg.php' for inclusion [include_path='.:/usr/share/php'] in /home/aed0ed3b35fece41022f332aba5c9b45.php on line 5
9PHP 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
50PHP 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
4PHP 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
3PHP 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
53PHP 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
7PHP 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
6PHP Warning: include[gfg.php]: failed to open stream: No such file or directory in /home/aed0ed3b35fece41022f332aba5c9b45.php on line 5 PHP Warning: include[]: Failed opening 'gfg.php' for inclusion [include_path='.:/usr/share/php'] in /home/aed0ed3b35fece41022f332aba5c9b45.php on line 5
9PHP 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
3PHP 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
58PHP 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
59PHP 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
50PHP 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
6PHP 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
32PHP 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
3PHP 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
34PHP 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
7PHP 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
36PHP Warning: include[gfg.php]: failed to open stream: No such file or directory in /home/aed0ed3b35fece41022f332aba5c9b45.php on line 5 PHP Warning: include[]: Failed opening 'gfg.php' for inclusion [include_path='.:/usr/share/php'] in /home/aed0ed3b35fece41022f332aba5c9b45.php on line 5
3______43____75______07PHP 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
21PHP Warning: include[gfg.php]: failed to open stream: No such file or directory in /home/aed0ed3b35fece41022f332aba5c9b45.php on line 5 PHP Warning: include[]: Failed opening 'gfg.php' for inclusion [include_path='.:/usr/share/php'] in /home/aed0ed3b35fece41022f332aba5c9b45.php on line 5
1PHP 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
23PHP 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____75______07PHP 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
21PHP 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
9Lỗ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
- 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
29PHP Warning: include[gfg.php]: failed to open stream: No such file or directory in /home/aed0ed3b35fece41022f332aba5c9b45.php on line 5 PHP Warning: include[]: Failed opening 'gfg.php' for inclusion [include_path='.:/usr/share/php'] in /home/aed0ed3b35fece41022f332aba5c9b45.php on line 5
1PHP 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
3PHP 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
4PHP 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
33PHP 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
6PHP Warning: include[gfg.php]: failed to open stream: No such file or directory in /home/aed0ed3b35fece41022f332aba5c9b45.php on line 5 PHP Warning: include[]: Failed opening 'gfg.php' for inclusion [include_path='.:/usr/share/php'] in /home/aed0ed3b35fece41022f332aba5c9b45.php on line 5
1PHP 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
36PHP 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
37____438PHP 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
21PHP Warning: include[gfg.php]: failed to open stream: No such file or directory in /home/aed0ed3b35fece41022f332aba5c9b45.php on line 5 PHP Warning: include[]: Failed opening 'gfg.php' for inclusion [include_path='.:/usr/share/php'] in /home/aed0ed3b35fece41022f332aba5c9b45.php on line 5
1PHP 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
3PHP 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
3PHP 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____444PHP 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
6PHP 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
9Lỗi
PHP Warning: include[gfg.php]: failed to open stream: No such file or directory in /home/aed0ed3b35fece41022f332aba5c9b45.php on line 5 PHP Warning: include[]: Failed opening 'gfg.php' for inclusion [include_path='.:/usr/share/php'] in /home/aed0ed3b35fece41022f332aba5c9b45.php on line 5
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 nghiêm trọng trong PHP là gì?
Lỗi nghiêm trọng khi khởi động. Lỗi này xảy ra khi hệ thống không thể chạy mã trong quá trình cài đặt . Thời gian biên dịch lỗi nghiêm trọng. Lỗi này xảy ra nếu lệnh gọi được thực hiện với một mã hoặc biến không tồn tại. Thời gian chạy lỗi nghiêm trọng. Lỗi này xảy ra trong khi chương trình đang chạy và sẽ khiến chương trình ngừng hoạt động.Sự khác biệt giữa cảnh báo và lỗi là gì?
CẢNH BÁO. Một cái gì đó đã không hoạt động như nó nên. Điều này có thể có tầm quan trọng lớn hơn hoặc ít hơn tùy thuộc vào hoàn cảnh. e. g. Không tìm thấy tệp đầu vào hoặc có định dạng sai. LỖI. Đã xảy ra sự cố '`nghiêm trọng''Cảnh báo PHP nghĩa là gì?
Lỗi cảnh báo trong PHP không ngăn tập lệnh chạy. Nó chỉ cảnh báo bạn rằng có một vấn đề, một vấn đề có khả năng gây ra những vấn đề lớn hơn trong tương lai . Các nguyên nhân phổ biến nhất của lỗi cảnh báo là. Gọi một tệp bên ngoài không tồn tại trong thư mục. Tham số sai trong hàm.Sự khác biệt giữa gây tử vong và lỗi là gì?
Lỗi logic [e. g. , khi cả hai dấu ngoặc nhọn trong một khối bị loại bỏ] có hiệu lực tại thời điểm thực hiện. Lỗi logic nghiêm trọng khiến ứng dụng bị lỗi và chấm dứt sớm . Lỗi logic không nghiêm trọng cho phép ứng dụng tiếp tục thực thi nhưng khiến ứng dụng tạo ra kết quả không chính xác.