displaying page name.<

liunx

Guest
Hi, I was wondering if there is a php code to display the page name of the current file you are visiting. I want to make a header script for my pages and just want to type in "RKS UnderGround > pagename here.

Using a code where pagename is displayed.

Thanks.

P.S. I am currently looking at the php funcion lists, but not luck so far.you could do a function like


<? function displayPageName($name, $link) { ?>
» <a href=http://www.htmlforums.com/archive/index.php/"<?=$link?>"><?=$name?></a>
<?}?>


and in your page

<a href=http://www.htmlforums.com/archive/index.php/"/">home</a><? displayPageName('about', 'about.php');?>


hth or at least gets you in the right track :)thanks, but where would I put the function code?you can put it in another file with all you other functions or on the same page... at the top like


<? function displayPageName($name, $link) { ?>
» <a href=http://www.htmlforums.com/archive/index.php/"<?=$link?>"><?=$name?></a>
<?}?>

<h1>About</h1>
<!-- breadcrums -->
<a href=http://www.htmlforums.com/archive/index.php/"/">home</a><? displayPageName('about', 'about.php');?>Thanks, where about.php is do I change that to the file I am currently using the code in?

And just out of curiousity, is there a way to break down that code do get the filename and display it, I wasnt planing on using links. If there isnt that way works fine, Thanks:DThanks, where about.php is do I change that to the file I am currently using the code in?

yes... it was just an example. you don't need to do it exactly like that... you could just have


<? function displayPageName($name) {
}?>


or whatever you want

And just out of curiousity, is there a way to break down that code do get the filename and display it, I wasnt planing on using links. If there isnt that way works fine, Thanks

:rolleyes:


<? function displayPageName($name) {?>
<h1><?=$name?></h1>
<?}?>


you can do whatever you want with functions... you created them!Thanks SO MUCH!no problem ;)could echo be used to display as you have to replace:
<h1><?=$name?></h1>
<?}?>

And use something like this:

<?php echo "$name" ?>

I am just wondering,

xxnfg618xx <--- PHP N00b, :D<?=$name?> is shorthand for <?php echo $name ?>, yes. But lose the quotes around $name, they are not needed, and actually adds unnecessary work for the preprocessor.
I always use the full <?php echo $name; ?> since short_open_tag is a configuration setting, which may not be enabled on all servers.Short <? blahblah ?> tags can cause problems in XML and XHTML, so you are best to use long <?php blahblah ?> tags instead.
 
Back
Top