In a custom page you call as a template in WordPress, this is the standard way to access some of the information about the particular post or page being viewed. This is possible by accessing the WordPress query object, which is already instantiated by WordPress in a global class called $wp_query. There is much more information you can get from this object, by visiting WordPress.org. Another interesting aspect of accessing the $wp_query object is that you can override many of the properties and methods within this class to alter the functions, data, and output of the containing page so you can tailor the page for further customization.
echo “Pagename: $pagename / Cat: $category_name / Url: $url / Author: $post_author”;
For custom pages, do not ever close your files with closing PHP tags with scripts. Please note that different WordPress themes like Genesis may have different functions that will either alter how you can access the $wp_query object and in some instances do not allow accessing it.