WordPress 中文文档
Function Reference/WP Error
From WordPress Chinese
目录 |
[编辑]
About: Role of WP_Error
Instroduced with WordPress 2.1, WP_Error is a class that makes error handling within plugins and WordPress itself much easier.
Instances of WP_Error store error codes and messages representing one or more errors, and whether or not a variable is an instance of WP_Error can be determined using the is_wp_error() function.
[编辑]
Code
You may find the class WP_Error in your file /wp-includes/classes.php at line 299 and function is_wp_error() at line 377. You can also view this file online at the trac.
[编辑]
Methods and Properties
[编辑]
Properties
[编辑]
Methods
[编辑]
Example
function doer_of_stuff() {
return new WP_Error('broke', __("I've fallen and can't get up"));
}
$return = doer_of_stuff();
if ( is_wp_error($return) )
echo $return->get_error_message();
[编辑]
External Links
- Introduction to WP_Error - tutorial with examples
