intl_error_name

Get symbolic name for a given error code

说明

string intl_error_name ( int $error_code )

Return ICU error code name.

参数

error_code
ICU error code.

返回值

The returned string will be the same as the name of the error code constant.

范例

示例 #1 intl_error_name example

<?php
$coll     = collator_create( 'en_RU' );
$err_code = collator_get_error_code( $coll );

printf( "Symbolic name for %d is %s\n.", $err_code, intl_error_name( $err_code ) );
?>

以上例程的输出类似于:

Symbolic name for -128 is U_USING_FALLBACK_WARNING.

参见

  • intl_is_failure
  • intl_get_error_code
  • intl_get_error_message

intl_get_error_code

Get the last error code

说明

int intl_get_error_code ( void )

Useful to handle errors occurred in static methods when there's no object to get error code from.

返回值

Error code returned by the last API function call.

范例

示例 #1 intl_get_error_code example

<?php
$coll = collator_create( '<bad_param>' );
if( !$coll ) {
    handle_error( intl_get_error_code() );
}
?>

参见

  • intl_is_failure
  • intl_error_name
  • intl_get_error_message
  • collator_get_error_code
  • numfmt_get_error_code

intl_get_error_message

Get description of the last error

说明

string intl_get_error_message ( void )

Get error message from last internationalization function called.

返回值

Description of an error occurred in the last API function call.

范例

示例 #1 intl_get_error_message example

<?php
if( Collator::getAvailableLocales() === false ) {
    show_error( intl_get_error_message() );
}
?>

参见

  • intl_error_name
  • intl_get_error_code
  • intl_is_failure
  • collator_get_error_message
  • numfmt_get_error_message

intl_is_failure

Check whether the given error code indicates failure

说明

bool intl_is_failure ( int $error_code )

参数

error_code
is a value that returned by functions: intl_get_error_code, collator_get_error_code .

返回值

TRUE if it the code indicates some failure, and FALSE in case of success or a warning.

范例

示例 #1 intl_is_failure example

<?php
function check( $err_code )
{
    var_export( intl_is_failure( $err_code ) );
    echo "\n";
}

check( U_ZERO_ERROR );
check( U_USING_FALLBACK_WARNING );
check( U_ILLEGAL_ARGUMENT_ERROR );
?>

以上例程的输出类似于:

false
false
true

参见

  • intl_get_error_code
  • collator_get_error_code
  • Collator-getErrorCode

目录