Hướng dẫn what is the use of error reporting function in php? - việc sử dụng chức năng báo lỗi trong php là gì?

Tham chiếu lỗi PHP

Thí dụ

Chỉ định báo cáo mức độ lỗi khác nhau:

// Turn off error reporting
error_reporting(0);

// Báo cáo lỗi thời gian chạy error_Reporting (e_error | e_warning | e_parse);
error_reporting(E_ERROR | E_WARNING | E_PARSE);

// Báo cáo tất cả các lỗi ERROR_Reporting (e_all);
error_reporting(E_ALL);

// Tương tự như error_Reporting (e_all); ini_set ("error_reporting", e_all);
ini_set("error_reporting", E_ALL);

// báo cáo tất cả các lỗi ngoại trừ e_notice error_Reporting (e_all & ~ e_notice); ?>
error_reporting(E_ALL & ~E_NOTICE);
?>



Định nghĩa và cách sử dụng

Hàm error_Reporting () chỉ định các lỗi nào được báo cáo.

PHP có nhiều mức độ lỗi và sử dụng chức năng này đặt mức đó cho tập lệnh hiện tại.


Cú pháp

Giá trị tham số

Tham sốSự mô tả
mức độKhông bắt buộc. Chỉ định mức báo cáo lỗi cho tập lệnh hiện tại. Số lỗi và hằng số được đặt tên được chấp nhận. Lưu ý: Các hằng số được đặt tên được khuyến nghị để đảm bảo khả năng tương thích cho các phiên bản PHP trong tương laiNote: Named constants are recommended to ensure compatibility for future PHP versions


Chi tiết kỹ thuật

Giá trị trở lại:Trả về mức báo cáo lỗi cũ hoặc cấp báo cáo lỗi hiện tại nếu không có tham số cấp độ nào
Phiên bản PHP:4.0+
PHP Changelog:Php 5.4: e_strict hiện là một phần của e_all.php 5.3: Mới: e_deprecated và e_user_deprecated.php 5.2: Mới:
PHP 5.3: New: E_DEPRECATED and E_USER_DEPRECATED.
PHP 5.2: New: E_RECOVERABLE_ERROR.
PHP 5.0: New: E_STRICT.

Tham chiếu lỗi PHP


22 năm trước

Alex ¶Sets which PHP errors are reported

Sự mô tả

15 năm trước(?int $error_level = null): int

Thông số

error_level

Mức độ lỗi mới. Nó có một hoặc một hằng số được đặt tên. Sử dụng các hằng số được đặt tên được khuyến khích mạnh mẽ để đảm bảo khả năng tương thích cho các phiên bản trong tương lai. Khi các mức lỗi được thêm vào, phạm vi số nguyên tăng, do đó các mức lỗi dựa trên số nguyên cũ sẽ không luôn luôn hoạt động như mong đợi.

Các hằng số mức lỗi có sẵn và ý nghĩa thực tế của các mức lỗi này được mô tả trong các hằng số được xác định trước.

Trả về giá trị

Trả về mức ERROR_REPORTING cũ hoặc mức hiện tại nếu không có tham số error_level được đưa ra.

Thay đổi

Phiên bảnSự mô tả
8.0.0 error_level bây giờ là không thể.

Ví dụ

Ví dụ #1 Error_Reporting () Ví dụerror_reporting() examples

<?php// Turn off all error reporting
error_reporting(0);// Report simple running errors
error_reporting(E_ERROR E_WARNING E_PARSE);// Reporting E_NOTICE can be good too (to report uninitialized
// variables or catch variable name misspellings ...)
error_reporting(E_ERROR E_WARNING E_PARSE E_NOTICE);// Report all errors except E_NOTICE
error_reporting(E_ALL & ~E_NOTICE);// Report all PHP errors
error_reporting(E_ALL);// Report all PHP errors
error_reporting(-1);// Same as error_reporting(E_ALL);
ini_set('error_reporting'E_ALL);?>

Ghi chú

Mẹo

Truyền trong giá trị -1 sẽ hiển thị mọi lỗi có thể xảy ra, ngay cả khi các cấp độ và hằng số mới được thêm vào các phiên bản PHP trong tương lai. Hành vi tương đương với việc vượt qua E_ALL hằng số.E_ALL constant.

Xem thêm

  • Chỉ thị Display_errors
  • Chỉ thị HTML_ERRORS
  • Chỉ thị XMLRPC_ERRORS
  • ini_set () - Đặt giá trị của tùy chọn cấu hình

Thông tin tại Hephoz Dot de ¶

14 năm trước

If you just see a blank page instead of an error reporting and you have no server access so you can't edit php configuration files like php.ini try this:

- create a new file in which you include the faulty script:

null0

null1

null2

jcastromail tại yahoo dot es ¶

1 năm trước

null3

null4

null5

null6

null7

Dave tại Davidhbrown dot chúng tôi ¶

16 năm trước

null8

null9

error_level0

null2

Piancastelli Fernando

17 năm trước

error_level2

error_level3

error_level4

null2

Luisdev ¶

4 năm trước

error_level6

error_level7

error_level8

error_level9

error_level0

null2

lhenry tại lhenry dot com

2 năm trước

error_level2

error_level3

error_level4

error_level5

null2

Adam tại Adamhahn dot com

5 năm trước

error_level7

error_level8

null2

Keithm tại Aoeex dot com ¶

12 năm trước

error_level0

error_level1

error_level2

error_level3

error_level4

null2

Qeremy! gmail ¶

7 năm trước

error_level6

error_level7

null2

Phát ban ¶

7 năm trước

error_level9

<?php// Turn off all error reporting
error_reporting(0);// Report simple running errors
error_reporting(E_ERROR E_WARNING E_PARSE);// Reporting E_NOTICE can be good too (to report uninitialized
// variables or catch variable name misspellings ...)
error_reporting(E_ERROR E_WARNING E_PARSE E_NOTICE);// Report all errors except E_NOTICE
error_reporting(E_ALL & ~E_NOTICE);// Report all PHP errors
error_reporting(E_ALL);// Report all PHP errors
error_reporting(-1);// Same as error_reporting(E_ALL);
ini_set('error_reporting'E_ALL);?>
0

null2

Phát ban ¶

4 năm trước

<?php// Turn off all error reporting
error_reporting(0);// Report simple running errors
error_reporting(E_ERROR E_WARNING E_PARSE);// Reporting E_NOTICE can be good too (to report uninitialized
// variables or catch variable name misspellings ...)
error_reporting(E_ERROR E_WARNING E_PARSE E_NOTICE);// Report all errors except E_NOTICE
error_reporting(E_ALL & ~E_NOTICE);// Report all PHP errors
error_reporting(E_ALL);// Report all PHP errors
error_reporting(-1);// Same as error_reporting(E_ALL);
ini_set('error_reporting'E_ALL);?>
2

lhenry tại lhenry dot com

2 năm trước

<?php// Turn off all error reporting
error_reporting(0);// Report simple running errors
error_reporting(E_ERROR E_WARNING E_PARSE);// Reporting E_NOTICE can be good too (to report uninitialized
// variables or catch variable name misspellings ...)
error_reporting(E_ERROR E_WARNING E_PARSE E_NOTICE);// Report all errors except E_NOTICE
error_reporting(E_ALL & ~E_NOTICE);// Report all PHP errors
error_reporting(E_ALL);// Report all PHP errors
error_reporting(-1);// Same as error_reporting(E_ALL);
ini_set('error_reporting'E_ALL);?>
3

<?php// Turn off all error reporting
error_reporting(0);// Report simple running errors
error_reporting(E_ERROR E_WARNING E_PARSE);// Reporting E_NOTICE can be good too (to report uninitialized
// variables or catch variable name misspellings ...)
error_reporting(E_ERROR E_WARNING E_PARSE E_NOTICE);// Report all errors except E_NOTICE
error_reporting(E_ALL & ~E_NOTICE);// Report all PHP errors
error_reporting(E_ALL);// Report all PHP errors
error_reporting(-1);// Same as error_reporting(E_ALL);
ini_set('error_reporting'E_ALL);?>
4

null2

Adam tại Adamhahn dot com

14 năm trước

<?php// Turn off all error reporting
error_reporting(0);// Report simple running errors
error_reporting(E_ERROR E_WARNING E_PARSE);// Reporting E_NOTICE can be good too (to report uninitialized
// variables or catch variable name misspellings ...)
error_reporting(E_ERROR E_WARNING E_PARSE E_NOTICE);// Report all errors except E_NOTICE
error_reporting(E_ALL & ~E_NOTICE);// Report all PHP errors
error_reporting(E_ALL);// Report all PHP errors
error_reporting(-1);// Same as error_reporting(E_ALL);
ini_set('error_reporting'E_ALL);?>
6

<?php// Turn off all error reporting
error_reporting(0);// Report simple running errors
error_reporting(E_ERROR E_WARNING E_PARSE);// Reporting E_NOTICE can be good too (to report uninitialized
// variables or catch variable name misspellings ...)
error_reporting(E_ERROR E_WARNING E_PARSE E_NOTICE);// Report all errors except E_NOTICE
error_reporting(E_ALL & ~E_NOTICE);// Report all PHP errors
error_reporting(E_ALL);// Report all PHP errors
error_reporting(-1);// Same as error_reporting(E_ALL);
ini_set('error_reporting'E_ALL);?>
7

<?php// Turn off all error reporting
error_reporting(0);// Report simple running errors
error_reporting(E_ERROR E_WARNING E_PARSE);// Reporting E_NOTICE can be good too (to report uninitialized
// variables or catch variable name misspellings ...)
error_reporting(E_ERROR E_WARNING E_PARSE E_NOTICE);// Report all errors except E_NOTICE
error_reporting(E_ALL & ~E_NOTICE);// Report all PHP errors
error_reporting(E_ALL);// Report all PHP errors
error_reporting(-1);// Same as error_reporting(E_ALL);
ini_set('error_reporting'E_ALL);?>
8

<?php// Turn off all error reporting
error_reporting(0);// Report simple running errors
error_reporting(E_ERROR E_WARNING E_PARSE);// Reporting E_NOTICE can be good too (to report uninitialized
// variables or catch variable name misspellings ...)
error_reporting(E_ERROR E_WARNING E_PARSE E_NOTICE);// Report all errors except E_NOTICE
error_reporting(E_ALL & ~E_NOTICE);// Report all PHP errors
error_reporting(E_ALL);// Report all PHP errors
error_reporting(-1);// Same as error_reporting(E_ALL);
ini_set('error_reporting'E_ALL);?>
9

null2

jcastromail tại yahoo dot es ¶

1 năm trước

-11

-12

-13

-14

-15

-16

-17

null2

Dave tại Davidhbrown dot chúng tôi ¶

16 năm trước

-19

E_ALL0

E_ALL1

null2

Piancastelli Fernando

5 năm trước

E_ALL3

Keithm tại Aoeex dot com ¶

17 năm trước

E_ALL4

Luisdev ¶

17 năm trước

E_ALL5

E_ALL6

E_ALL7

E_ALL8

E_ALL9

If you just see a blank page instead of an error reporting and you have no server access so you can't edit php configuration files like php.ini try this:0

If you just see a blank page instead of an error reporting and you have no server access so you can't edit php configuration files like php.ini try this:1

If you just see a blank page instead of an error reporting and you have no server access so you can't edit php configuration files like php.ini try this:2

null2

Luisdev ¶

4 năm trước

If you just see a blank page instead of an error reporting and you have no server access so you can't edit php configuration files like php.ini try this:4

If you just see a blank page instead of an error reporting and you have no server access so you can't edit php configuration files like php.ini try this:5

If you just see a blank page instead of an error reporting and you have no server access so you can't edit php configuration files like php.ini try this:6

If you just see a blank page instead of an error reporting and you have no server access so you can't edit php configuration files like php.ini try this:7

If you just see a blank page instead of an error reporting and you have no server access so you can't edit php configuration files like php.ini try this:8

lhenry tại lhenry dot com

2 năm trước

If you just see a blank page instead of an error reporting and you have no server access so you can't edit php configuration files like php.ini try this:9

- create a new file in which you include the faulty script:0

null2

Adam tại Adamhahn dot com

4 năm trước

- create a new file in which you include the faulty script:2

- create a new file in which you include the faulty script:3

- create a new file in which you include the faulty script:4

null2

lhenry tại lhenry dot com

2 năm trước

- create a new file in which you include the faulty script:6

- create a new file in which you include the faulty script:7

null2

Adam tại Adamhahn dot com

5 năm trước

- create a new file in which you include the faulty script:9

null00

null01

null2

Keithm tại Aoeex dot com ¶

17 năm trước

null03

null04

null05

null2

Luisdev ¶

2 năm trước

null07

Làm cách nào để báo cáo lỗi trong PHP?

Cách nhanh nhất để hiển thị tất cả các lỗi và cảnh báo PHP là thêm các dòng này vào tệp mã PHP của bạn: ini_set ('display_errors', 1);ini_set ('display_startup_errors', 1);error_Reporting (e_all);Hàm ini_set sẽ cố gắng ghi đè cấu hình được tìm thấy trong PHP của bạn.Tệp INI.

Mục đích của việc xử lý lỗi trong PHP giải thích với ví dụ phù hợp là gì?

Xử lý lỗi là quá trình bắt các lỗi được đưa ra bởi chương trình của bạn và sau đó thực hiện hành động thích hợp.Nếu bạn sẽ xử lý các lỗi đúng thì nó có thể dẫn đến nhiều hậu quả không lường trước được.Nó rất đơn giản trong PHP để xử lý một lỗi.catching errors raised by your program and then taking appropriate action. If you would handle errors properly then it may lead to many unforeseen consequences. Its very simple in PHP to handle an errors.

Mức độ lỗi nào được sử dụng trong PHP?

Trong PHP, chủ yếu là bốn loại lỗi được xem xét:..
Lỗi cú pháp hoặc lỗi phân tích cú pháp ..
Lỗi nghiêm trọng..
Lỗi cảnh báo ..
Thông báo lỗi ..

Có bao nhiêu cấp độ báo cáo lỗi trong PHP?

Có bao nhiêu mức độ lỗi trong PHP?Có 16 mức độ lỗi trong PHP 5. Các lỗi này đại diện cho danh mục và đôi khi mức độ nghiêm trọng của một lỗi trong PHP.16 error levels in PHP 5. These errors represent the category and sometimes severity of an error in PHP.