New to php and need help on first function ever!
Posted: Tue Oct 28, 2008 11:52 am
~pickle | Please use [ code=html ], [ code=php ], etc tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:
Posting Code in the Forums to learn how to do it too.
So i'm trying to construct a function that does two things. Basically i'm trying to streamline some code that worked earlier but made the code too long and made me feel weird. I thought i'd try to slim it down a little bit. I'll paste the function here and describe what i'm trying to do with it after the paste. Unless you can tell what i'm trying to do w/o the explanation:
I'm trying to get the script to check for the page you're on, then i'm trying to color the link a hue of green. For the most part it works, but i somehow have to end that span class after the "home" link. Any help would be superly wonderful.
~pickle | Please use [ code=html ], [ code=php ], etc tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:
Posting Code in the Forums to learn how to do it too.
So i'm trying to construct a function that does two things. Basically i'm trying to streamline some code that worked earlier but made the code too long and made me feel weird. I thought i'd try to slim it down a little bit. I'll paste the function here and describe what i'm trying to do with it after the paste. Unless you can tell what i'm trying to do w/o the explanation:
Code: Select all
<?php
$currentpage = basename($_SERVER['SCRIPT_NAME']);
$selected = "<span style=\"color: #a8c26e;\">";
if ($currentpage) {
echo $selected;
}
?>Code: Select all
<a href="index.php" <?php $currentpage == ('index.php'); ?>>Home</a>~pickle | Please use [ code=html ], [ code=php ], etc tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: