Hướng dẫn which function throws error message in php file handling? - chức năng nào đưa ra thông báo lỗi khi xử lý tệp php?

Mục lục

  • DEBUG_BACKTRACE - tạo ra một backtrace
  • DEBUG_PRINT_BACKTRACE - In Backtrace
  • ERROR_CLEAR_LAST - Xóa lỗi gần đây nhất
  • ERROR_GET_LAST - Nhận lỗi xảy ra cuối cùng
  • ERROR_LOG - Gửi thông báo lỗi đến các thói quen xử lý lỗi đã xác định
  • Error_Reporting - Các bộ lỗi PHP được báo cáo
  • restore_error_handler - khôi phục chức năng xử lý lỗi trước đó
  • restore_exception_handler - khôi phục chức năng xử lý ngoại lệ được xác định trước đó
  • set_error_handler-Đặt chức năng xử lý lỗi do người dùng xác định
  • set_exception_handler-Đặt chức năng xử lý ngoại lệ do người dùng xác định
  • Trigger_error-Tạo thông báo lỗi/cảnh báo/thông báo cấp độ người dùng
  • user_error - Bí danh của Trigger_error

tracerdx tại tracerdx dot com ¶

16 năm trước

I keep seeing qualification lists for error types/error-nums as arrays; In user notes and in the manual itself. For example, in this manual entry's example, when trying to seperate behavior for the variable trace in the error report:

<?php //...

// set of errors for which a var trace will be saved

$user_errors = array(E_USER_ERROR, E_USER_WARNING, E_USER_NOTICE);//and later...if (in_array($errno, $user_errors)) {
   
//...whatever
}//... ?>

I was under the impression that PHP error code values where bitwise flag values. Wouldn't bitwise masking be better? So I propose a slightly better way:
<?php //...$user_errors = E_USER_ERROR | E_USER_WARNING | E_USER_NOTICE;//...blah...if ($errno & $user_errors) {
   
//...whatever
}//... ?>
Or for those of you who don't like the idea of using an integer as the condition in an if statement:

<?php
if (($errno & $user_errors) > 0) {
   
//...whatever
}
?>

I think that's much more efficient than using _yet another_ array() constuct and an in_array().

If I am wrong, and the E_* constants aren't supposed to be used in this fashion (ie, the constans aren't guaranteed to be bitwise, which would be odd since that's how they're setup in the php.ini file), then delete me. I just don't see why one should be using arrays when bitwise comparisons will work, considering the bitwise method should be MUCH more efficient.

shawing tại gmail dot com

17 năm trước

Although the root user writes to the files 'error_log' and 'access_log', the Apache user has to own the file referenced by 'error_log = filename' or no log entries will be written.

; From php.ini
; Log errors to specified file.
error_log = /usr/local/apache/logs/php.errors

[root@www logs]$ ls -l /usr/local/apache/logs/php.errors
-rw-r--r--    1 nobody   root          27K Jan 27 16:58 php.errors

ptah tại se dot linux dot org ¶

18 năm trước

PHP5 only (only tested with php5.0).

If you, for some reason, prefer exceptions over errors and have your custom error handler (set_error_handler) wrap the error into an exception you have to be careful with your script.

<?php //...0

<?php //...1

<?php //...2

<?php //...3

<?php //...4

Stephen ¶

15 năm trước

<?php //...5

<?php //...6

mortonda tại dgmm dot net ¶

15 năm trước

<?php //...8

mortonda tại dgmm dot net ¶

17 năm trước

<?php //...9

// set of errors for which a var trace will be saved0

// set of errors for which a var trace will be saved1

// set of errors for which a var trace will be saved2

// set of errors for which a var trace will be saved3

// set of errors for which a var trace will be saved4

// set of errors for which a var trace will be saved5

// set of errors for which a var trace will be saved6

ptah tại se dot linux dot org ¶

16 năm trước

// set of errors for which a var trace will be saved8

// set of errors for which a var trace will be saved9

<?php //...3

$user_errors = array(E_USER_ERROR, E_USER_WARNING, E_USER_NOTICE);//and later...if (in_array($errno, $user_errors)) {
   
//...whatever
}//... ?>

I was under the impression that PHP error code values where bitwise flag values. Wouldn't bitwise masking be better? So I propose a slightly better way:
<?php //...$user_errors = E_USER_ERROR | E_USER_WARNING | E_USER_NOTICE;//...blah...if ($errno & $user_errors) {
   
//...whatever
}//... ?>
Or for those of you who don't like the idea of using an integer as the condition in an if statement:

<?php
if (($errno & $user_errors) > 0) {
   
//...whatever
}
?>

I think that's much more efficient than using _yet another_ array() constuct and an in_array().

If I am wrong, and the E_* constants aren't supposed to be used in this fashion (ie, the constans aren't guaranteed to be bitwise, which would be odd since that's how they're setup in the php.ini file), then delete me. I just don't see why one should be using arrays when bitwise comparisons will work, considering the bitwise method should be MUCH more efficient.

1

shawing tại gmail dot com

15 năm trước

$user_errors = array(E_USER_ERROR, E_USER_WARNING, E_USER_NOTICE);//and later...if (in_array($errno, $user_errors)) {
   
//...whatever
}//... ?>

I was under the impression that PHP error code values where bitwise flag values. Wouldn't bitwise masking be better? So I propose a slightly better way:
<?php //...$user_errors = E_USER_ERROR | E_USER_WARNING | E_USER_NOTICE;//...blah...if ($errno & $user_errors) {
   
//...whatever
}//... ?>
Or for those of you who don't like the idea of using an integer as the condition in an if statement:

<?php
if (($errno & $user_errors) > 0) {
   
//...whatever
}
?>

I think that's much more efficient than using _yet another_ array() constuct and an in_array().

If I am wrong, and the E_* constants aren't supposed to be used in this fashion (ie, the constans aren't guaranteed to be bitwise, which would be odd since that's how they're setup in the php.ini file), then delete me. I just don't see why one should be using arrays when bitwise comparisons will work, considering the bitwise method should be MUCH more efficient.

2

mortonda tại dgmm dot net ¶

15 năm trước

$user_errors = array(E_USER_ERROR, E_USER_WARNING, E_USER_NOTICE);//and later...if (in_array($errno, $user_errors)) {
   
//...whatever
}//... ?>

I was under the impression that PHP error code values where bitwise flag values. Wouldn't bitwise masking be better? So I propose a slightly better way:
<?php //...$user_errors = E_USER_ERROR | E_USER_WARNING | E_USER_NOTICE;//...blah...if ($errno & $user_errors) {
   
//...whatever
}//... ?>
Or for those of you who don't like the idea of using an integer as the condition in an if statement:

<?php
if (($errno & $user_errors) > 0) {
   
//...whatever
}
?>

I think that's much more efficient than using _yet another_ array() constuct and an in_array().

If I am wrong, and the E_* constants aren't supposed to be used in this fashion (ie, the constans aren't guaranteed to be bitwise, which would be odd since that's how they're setup in the php.ini file), then delete me. I just don't see why one should be using arrays when bitwise comparisons will work, considering the bitwise method should be MUCH more efficient.

3

$user_errors = array(E_USER_ERROR, E_USER_WARNING, E_USER_NOTICE);//and later...if (in_array($errno, $user_errors)) {
   
//...whatever
}//... ?>

I was under the impression that PHP error code values where bitwise flag values. Wouldn't bitwise masking be better? So I propose a slightly better way:
<?php //...$user_errors = E_USER_ERROR | E_USER_WARNING | E_USER_NOTICE;//...blah...if ($errno & $user_errors) {
   
//...whatever
}//... ?>
Or for those of you who don't like the idea of using an integer as the condition in an if statement:

<?php
if (($errno & $user_errors) > 0) {
   
//...whatever
}
?>

I think that's much more efficient than using _yet another_ array() constuct and an in_array().

If I am wrong, and the E_* constants aren't supposed to be used in this fashion (ie, the constans aren't guaranteed to be bitwise, which would be odd since that's how they're setup in the php.ini file), then delete me. I just don't see why one should be using arrays when bitwise comparisons will work, considering the bitwise method should be MUCH more efficient.

4

$user_errors = array(E_USER_ERROR, E_USER_WARNING, E_USER_NOTICE);//and later...if (in_array($errno, $user_errors)) {
   
//...whatever
}//... ?>

I was under the impression that PHP error code values where bitwise flag values. Wouldn't bitwise masking be better? So I propose a slightly better way:
<?php //...$user_errors = E_USER_ERROR | E_USER_WARNING | E_USER_NOTICE;//...blah...if ($errno & $user_errors) {
   
//...whatever
}//... ?>
Or for those of you who don't like the idea of using an integer as the condition in an if statement:

<?php
if (($errno & $user_errors) > 0) {
   
//...whatever
}
?>

I think that's much more efficient than using _yet another_ array() constuct and an in_array().

If I am wrong, and the E_* constants aren't supposed to be used in this fashion (ie, the constans aren't guaranteed to be bitwise, which would be odd since that's how they're setup in the php.ini file), then delete me. I just don't see why one should be using arrays when bitwise comparisons will work, considering the bitwise method should be MUCH more efficient.

5

$user_errors = array(E_USER_ERROR, E_USER_WARNING, E_USER_NOTICE);//and later...if (in_array($errno, $user_errors)) {
   
//...whatever
}//... ?>

I was under the impression that PHP error code values where bitwise flag values. Wouldn't bitwise masking be better? So I propose a slightly better way:
<?php //...$user_errors = E_USER_ERROR | E_USER_WARNING | E_USER_NOTICE;//...blah...if ($errno & $user_errors) {
   
//...whatever
}//... ?>
Or for those of you who don't like the idea of using an integer as the condition in an if statement:

<?php
if (($errno & $user_errors) > 0) {
   
//...whatever
}
?>

I think that's much more efficient than using _yet another_ array() constuct and an in_array().

If I am wrong, and the E_* constants aren't supposed to be used in this fashion (ie, the constans aren't guaranteed to be bitwise, which would be odd since that's how they're setup in the php.ini file), then delete me. I just don't see why one should be using arrays when bitwise comparisons will work, considering the bitwise method should be MUCH more efficient.

6

$user_errors = array(E_USER_ERROR, E_USER_WARNING, E_USER_NOTICE);//and later...if (in_array($errno, $user_errors)) {
   
//...whatever
}//... ?>

I was under the impression that PHP error code values where bitwise flag values. Wouldn't bitwise masking be better? So I propose a slightly better way:
<?php //...$user_errors = E_USER_ERROR | E_USER_WARNING | E_USER_NOTICE;//...blah...if ($errno & $user_errors) {
   
//...whatever
}//... ?>
Or for those of you who don't like the idea of using an integer as the condition in an if statement:

<?php
if (($errno & $user_errors) > 0) {
   
//...whatever
}
?>

I think that's much more efficient than using _yet another_ array() constuct and an in_array().

If I am wrong, and the E_* constants aren't supposed to be used in this fashion (ie, the constans aren't guaranteed to be bitwise, which would be odd since that's how they're setup in the php.ini file), then delete me. I just don't see why one should be using arrays when bitwise comparisons will work, considering the bitwise method should be MUCH more efficient.

7

Chức năng nào được sử dụng để xử lý lỗi PHP?

Trong một tập lệnh nơi người dùng có thể nhập dữ liệu, rất hữu ích khi kích hoạt lỗi khi xảy ra đầu vào bất hợp pháp.Trong PHP, điều này được thực hiện bởi hàm Trigger_error ().trigger_error() function.

Hàm nào trả về thông báo lỗi trong PHP?

Lỗi PHP và chức năng ghi nhật ký.

Hàm xử lý lỗi tệp là gì?

Trong C/C ++, hàm thư viện ferror () được sử dụng để kiểm tra lỗi trong luồng.Nguyên mẫu của nó được viết là: int ferror (file *stream);Hàm ferror () kiểm tra mọi lỗi trong luồng.Nó trả về giá trị 0 nếu không có lỗi nào xảy ra và giá trị khác không nếu có lỗi.ferror() is used to check for the error in the stream. Its prototype is written as: int ferror (FILE *stream); The ferror() function checks for any error in the stream. It returns a value zero if no error has occurred and a non-zero value if there is an error.

Làm thế nào tôi có thể nhận được lỗi trong PHP?

Hãy thử, ném và bắt..
Hãy thử - một chức năng sử dụng một ngoại lệ phải nằm trong khối "thử".Nếu ngoại lệ không kích hoạt, mã sẽ tiếp tục như bình thường.....
Ném - Đây là cách bạn kích hoạt một ngoại lệ.....
Bắt - Khối "bắt" lấy một ngoại lệ và tạo một đối tượng chứa thông tin ngoại lệ ..