Displaying a menu title in Joomla

<?php
  $app = JFactory::getApplication();
  $menu = $app->getMenu();
  $menuname = $menu->getActive()->title;
  echo $menuname
 ?>