Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

PHP Build a Simple PHP Application Creating the Menu and Footer Including the Header

Boris Vukobrat
Boris Vukobrat
4,248 Points

Contact link not working

In header.php I have

<li class="contact"><a href="contact.php">Contact</a></li>

but isn't working in browser. I thought should use

href="../contact.php"```
since *header.php* is one level below *contact.php*, but still link doesn't work.

So first, to clear this up, if *index.php* and *contact.php* are at the same level, links from included **.php** files are referencing as they were originally within *index.php*? 

So what if we'd like to include *header.php* in other file that isn't at the same level as *index.php*?

And finally, where could be the problem for my link isn't working? (everything else works)

1 Answer

Hugo Paz
Hugo Paz
15,622 Points

Hi Boris,

The include() function takes all the text in a specified file and copies it into the file that uses the include function.

Do you have any other links on your header?

Boris Vukobrat
Boris Vukobrat
4,248 Points

Ok, I understand that. Whole header.php is copied into index.php.

But, I found what was the problem. I played to much with the xampp server. I work on files at the separate folder and then copy them to my own local server. Why? Cause I have more projects in htdocs. And they are all in separate folders. Then, in all those 'transforms', I left original index.php with html header in it, and apart from that, I opened some files with file://C:/xampp/htdocs/... instead of http://localhost/xampp/htdocs/... so php code didn't work.

Thanks Hugo, good experience for me, didn't think of that, and should focus on one action at a time. : ))