zang8027 Posted July 18, 2009 Share Posted July 18, 2009 I got a php file called nav.php with the following code: <?php function navigation($home, $resume, $port, $contact) { echo ' <ul> <li><a href="index/"><img src="images/$home.png" alt="Home Page" /></a></li> <li><a href="resume/"><img src="images/$resume.png" alt="Resume" /></a></li> <li><a href="portfolio/"><img src="images/$port.png" alt="Portfolio Pieces" /></a></li> <li><a href="contact/"><img src="images/$contact.png" alt="Contact" /></a></li> </ul> '; } ?> Then, in my main file, i am using require_once 'nav.php';. Then, i am calling the function navigation("homeBtn", "resumeBtn", "portBtn", "contactBtn); I am getting $contact.png etc.. instead of contactBtn so it acts like its not accepting my params. Any idea? Link to comment https://forums.phpfreaks.com/topic/166389-solved-passing-params/ Share on other sites More sharing options...
Stephen Posted July 18, 2009 Share Posted July 18, 2009 You need to use double quotes instead of single quotes for it to show the value of the variable. Or you could just do, ' . $home . ' etc. So, <?php function navigation($home, $resume, $port, $contact) { echo ' <ul> <li><a href="index/"><img src="images/' . $home . '.png" alt="Home Page" /></a></li> <li><a href="resume/"><img src="images/' . $resume . '.png" alt="Resume" /></a></li> <li><a href="portfolio/"><img src="images/' . $port . '.png" alt="Portfolio Pieces" /></a></li> <li><a href="contact/"><img src="images/' . $contact . '.png" alt="Contact" /></a></li> </ul> '; } ?> is one way. Link to comment https://forums.phpfreaks.com/topic/166389-solved-passing-params/#findComment-877425 Share on other sites More sharing options...
zang8027 Posted July 18, 2009 Author Share Posted July 18, 2009 thank you, that worked Link to comment https://forums.phpfreaks.com/topic/166389-solved-passing-params/#findComment-877426 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.