(Php 5> = 5.2.0, Php 7, Php 8)
ERROR_GET_LAST - Nhận lỗi xảy ra cuối cùng — Get the last occurred error
Sự mô tả
ERROR_GET_LAST ():? Mảng(): ?array
Thông số
Chức năng này không có tham số.
Trả về giá trị
Trả về một mảng kết hợp mô tả lỗi cuối cùng với các khóa "Loại", "Tin nhắn", "Tệp" và "Line". Nếu lỗi đã được gây ra bởi hàm nội bộ PHP thì "thông báo" bắt đầu bằng tên của nó. Trả về null nếu chưa có lỗi.null if there hasn't been an error yet.
Ví dụ
Ví dụ #1 một ví dụ về error_get_last ()error_get_last() example
<?php
echo $a;
print_r(error_get_last());
?>
Ví dụ trên sẽ xuất ra một cái gì đó tương tự như:
Array ( [type] => 8 [message] => Undefined variable: a [file] => C:\WWW\index.php [line] => 2 )
Xem thêm
- Hằng số lỗi
- Biến $ PHP_ERRORMSG
- ERROR_CLEAR_LAST () - Xóa lỗi gần đây nhất
- Chỉ thị display_errors
- Chỉ thị html_errors
- Chỉ thị xmlrpc_errors
DMGX DOT Michael tại Gmail Dot Com ¶ ¶
11 năm trước
If an error handler (see set_error_handler ) successfully handles an error then that error will not be reported by this function.
Nicolas Dot Grekas+PHP tại Gmail Dot Com ¶ ¶
8 năm trước
[Editor's note: as of PHP 7.0.0 there is error_clear_last() to clear the most recent error.]
To clear error_get_last(), or put it in a well defined state, you should use the code below. It works even when a custom error handler has been set.
<?php
// var_dump or anything else, as this will never be called because of the 0
set_error_handler('var_dump', 0);
@$undef_var;
restore_error_handler();
// error_get_last() is now in a well known state:
// Undefined variable: undef_var
... // Do something
$e = error_get_last();
null0
null1Skrol29 ¶ ¶
12 năm trước
null2
null3
null4
null5
null6Michael tại getprink dot com ¶ ¶
13 năm trước
null7
null8
null9
<?php
echo $a;
print_r(error_get_last());
?>
0
echo $a;
print_r(error_get_last());
?> 1
Vike2000 tại miền Google Mail ¶ ¶
9 năm trước
<?php
echo $a;
print_r(error_get_last());
?>
2
<?php
echo $a;
print_r(error_get_last());
?>
3
Brad ¶ ¶
14 năm trước
<?php
echo $a;
print_r(error_get_last());
?>
5
<?php
echo $a;
print_r(error_get_last());
?>
6
<?php
echo $a;
print_r(error_get_last());
?>
7
echo $a;
print_r(error_get_last());
?> 8
Iant tại clickwt dot com ¶ ¶
12 năm trước
<?php
echo $a;
print_r(error_get_last());
?>
9
null9
<?php
echo $a;
print_r(error_get_last());
?>
0
Brad ¶ ¶
14 năm trước
display_errors3
Iant tại clickwt dot com ¶ ¶
11 năm trước
display_errors4
If an error handler (see set_error_handler ) successfully handles an error then that error will not be reported by this function. ¶
Nicolas Dot Grekas+PHP tại Gmail Dot Com ¶
display_errors5
display_errors6
display_errors7
display_errors88 năm trước ¶
12 năm trước
display_errors9
html_errors0
null6Michael tại getprink dot com ¶ ¶
14 năm trước
html_errors2
Iant tại clickwt dot com ¶ ¶
13 năm trước
html_errors3
html_errors4
null6