PHP | IntlCalendar getErrorMessage() Function
The IntlCalendar::getErrorMessage() function is an inbuilt function in PHP which is used to return the error message (if any error exist) associated with the error by using IntlCalendar::getErrorCode() or intlcal_get_error_code() function.
Syntax:
Parameters: This function uses single parameter $calendar which holds the calendar object on the procedural style interface.
Return Value: This function returns the error message which is associated with last error that occurred in a function call on this object or a string which indicates the non-existence of an error.
Below program illustrates the IntlCalendar::getErrorMessage() function in PHP:
Program:
<?php
ini_set ( 'date.timezone' , 'Asia/Calcutta' );
ini_set ( "intl.error_level" , E_WARNING);
$calendar = IntlCalendar::fromDateTime( '2019-03-21 09:19:29' );
var_dump( $calendar ->getErrorMessage());
$calendar ->fieldDifference(-34E403, IntlCalendar::FIELD_ZONE_OFFSET);
var_dump( $calendar ->getErrorMessage());
?>
|
Output:
PHP Warning: IntlCalendar::fieldDifference(): intlcal_field_difference: Call to ICU method has
failed in /home/22bd84b151f5397224d747dadc65338e.php on line 16
string(12) "U_ZERO_ERROR"
string(81) "intlcal_field_difference: Call to ICU method has failed: U_ILLEGAL_ARGUMENT_ERROR"
Reference: https://www.php.net/manual/en/intlcalendar.geterrormessage.php
Last Updated :
25 Sep, 2019
Like Article
Save Article
Share your thoughts in the comments
Please Login to comment...