Tag Archives: Functions

DateTime::getLastErrors()

It returns the warnings and errors .
Example

<?php
echo “<pre>”;
try {
$date = new DateTime(‘phpcodez’);
} catch (Exception $e) {
print_r(DateTime::getLastErrors());
}
?>

Output

Array
(
[warning_count] => 1
[warnings] => Array
(
[6] => Double timezone specification
)

[error_count] => 1
[errors] => Array
(
[0] => The timezone could not be found in the database
)

)

date_get_last_errors

It returns the warnings and errors and is an alias of DateTime::getLastErrors().
Example

<?php
echo “<pre>”;
$date = date_create(‘phpcodez’);
print_r(date_get_last_errors());
?>

Output

Array
(
[warning_count] => 1
[warnings] => Array
(
[6] => Double timezone specification
)

[error_count] => 1
[errors] => Array
(
[0] => The timezone could not be found in the database
)

)

wp_get_nav_menu_items

It returns the items added to a menu created from admin panel ( Appearance → Menus)

<?php $items = wp_get_nav_menu_items( $menu, $args ); ?>

Here $menu can menu name,id or slug

$args can be

<?php $args = array(
‘orderby’                => ‘menu_order’,
‘post_status’            => ‘publish’ );
?>