Friday, December 12, 2025
HomeLanguagesPHP | intl_is_failure() Function

PHP | intl_is_failure() Function

The intl_is_failure() function is an inbuilt function in PHP which is used to check whether the given error code indicates failure.

Syntax:

bool intl_is_failure( $error_code )

Parameters: This function accepts single parameter $error_code which is a value that returned by the functions intl_get_error_code(), collator_get_error_code().

Return Value: If the code indicates some failure then it returns True and in case of success or a warning it returns False.

Below programs illustrate the intl_is_failure() function in PHP:

Program 1:




<?php
  
// Function definition
function check( $err_code ) {
    var_export( intl_is_failure( $err_code ) );
    echo "\n";
}
  
// Function call using error_code as parameter
check( U_USING_FALLBACK_WARNING );
check( U_ILLEGAL_ARGUMENT_ERROR );
  
?>


Output:

false
true

Program 2:




<?php
  
// Function definition
function check( $err_code ) {
    var_export( intl_is_failure( $err_code ) );
    echo "\n";
}
  
// Declare an array which contains error_code
$arr = array( 
    U_ZERO_ERROR, 
    U_ILLEGAL_ARGUMENT_ERROR,
    U_USING_FALLBACK_WARNING,
);
  
// Loop to call function
foreach ($arr as $err) { 
              
    // Check each element as
    // code point data 
    check($err); 
} 
  
?>


Output:

false
true
false

Reference: https://www.php.net/manual/en/function.intl-is-failure.php

RELATED ARTICLES

Most Popular

Dominic
32445 POSTS0 COMMENTS
Milvus
105 POSTS0 COMMENTS
Nango Kala
6814 POSTS0 COMMENTS
Nicole Veronica
11952 POSTS0 COMMENTS
Nokonwaba Nkukhwana
12029 POSTS0 COMMENTS
Shaida Kate Naidoo
6949 POSTS0 COMMENTS
Ted Musemwa
7199 POSTS0 COMMENTS
Thapelo Manthata
6895 POSTS0 COMMENTS
Umr Jansen
6882 POSTS0 COMMENTS