IntlDateFormatter::getErrorCode

datefmt_get_error_code

(PHP 5 >= 5.3.0, PHP 7, PECL intl >= 1.0.0)

IntlDateFormatter::getErrorCode -- datefmt_get_error_codeLit le code d'erreur de la dernière opération

Description

Style orienté objet

public IntlDateFormatter::getErrorCode ( void ) : int

Style procédural

datefmt_get_error_code ( IntlDateFormatter $fmt ) : int

Lit le code d'erreur de la dernière opération.

Liste de paramètres

fmt

La ressource de formateur IntlDateFormatter.

Valeurs de retour

Le code d'erreur, une des valeurs UErrorCode. La valeur initiale est U_ZERO_ERROR.

Exemples

Exemple #1 Exemple avec datefmt_get_error_code()

<?php
$fmt 
datefmt_create(
    
'en_US',
    
IntlDateFormatter::FULL,
    
IntlDateFormatter::FULL,
    
'America/Los_Angeles',
    
IntlDateFormatter::GREGORIAN
);
$str datefmt_format($fmt);
if (!
$str) {
    
printf(
        
"Erreur : %s (%d)\n",
        
datefmt_get_error_message($fmt),
        
datefmt_get_error_code($fmt)
    );
}
?>

Exemple #2 Exemple orienté objet

<?php
$fmt 
= new IntlDateFormatter(
    
'en_US',
    
IntlDateFormatter::FULL,
    
IntlDateFormatter::FULL,
    
'America/Los_Angeles',
    
IntlDateFormatter::GREGORIAN
);
$str $fmt->format();
if (!
$str) {
    
printf(
        
"Erreur : %s (%d)\n",
        
$fmt->getErrorMessage(),
        
$fmt->getErrorCode()
    );
}
?>

L'exemple ci-dessus va afficher :

Erreur : U_ZERO_ERROR (0)

Voir aussi