Check if Page Slug Exists, then display that Page’s Title

looking at MySQL query in the function it becomes clear that though it matches the post_name and returns true or false. What you want to find is, if a page exists by its slug. So, in that case, the function you have chosen is wrong.

To get the page by title you can simply use:

$page = get_page_by_title( 'Sample Page' );
echo $page->title

Just in case if you want to get page by slug you can use following code:

function get_page_title_for_slug($page_slug) {

     $page = get_page_by_path( $page_slug , OBJECT );

     if ( isset($page) )
        return $page->post_title;
     else
        return "Match not found";
}

You may call above function like below:

echo "<h1>" . get_page_title_for_slug("sample-page") . "</h1>";

Let me know if that helps.