Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Serva's avatar
Level 2

can't bind href links to the nav.partial.

Source: PHP for Beginners, Season: Dynamic Websites, Episode PHP Partials.

I can't bind html href links like Jeff did in the Video.

Mine looks like this but still doesn't work. I tried various schemes, went to w3Schools, StackOverflow but nothing helped me. I am in deep frustration and don't know anymore.

Here is a snapshot of the nav.php:

            <a href="../../../PHPForBeginners/index.php"
               class="rounded-md bg-gray-900 px-3 py-2 text-sm font-medium text-white"
               aria-current="page">Home</a>
            <a href="/about.php"
               class="rounded-md px-3 py-2 text-sm font-medium text-gray-300 hover:bg-gray-700 hover:text-white">About
                Us</a>
            <a href="/contact.php"
               class="rounded-md px-3 py-2 text-sm font-medium text-gray-300 hover:bg-gray-700 hover:text-white">Contact</a>
            <a href="/mission.php"
               class="rounded-md px-3 py-2 text-sm font-medium text-gray-300 hover:bg-gray-700 hover:text-white">Our Mission</a>

PS: there is a div over it but when I put it up, the whole code disappears. I don't know why.

0 likes
7 replies
experimentor's avatar
href="../../../PHPForBeginners/index.php"

this should be

href="/"
1 like
Serva's avatar
Level 2

@experimentor Thank you for your reply, but that didn't help me. I compared the code with mine and copied it, but it still doesn't work. If the url path is specified along with a directory then it works, but without the directory it doesn't work. I tried to add the directory in the href path (that's why I added ../../). The directory is called PHPForBeginners. Maybe that helps?

experimentor's avatar
Level 25

How are you running your server? Are you using this like Jeff did:

php -S localhost:8888

I think your folder structure is this: PHPForBeginners/view/partials/nav.php

I think you are running the server from the partials folder. You should run the server from the root of your project - PHPForBeginners folder.

Then everything will work like in the lesson.

1 like
Serva's avatar
Level 2

@experimentor I think this is my problem. Whenever I start XAMPP, I do not go through the terminal, but go to the managerOSX of XAMPP to start the Apache servers. I will take another look at the course and do it exactly like Jeff but make the PHPForBeginners folder the root folder. I will let you know if this works.

1 like
Serva's avatar
Level 2

@experimentor I did not run my server like Jeff did. I did it by running the index.php on PHPStorm and working from there. By reading and watching more about xampp, I can do it much easier by clicking the "Go to Application" button when I open manager-osx. But without telling me to rewrite my root path so that it runs on my PHPForBeginners folder, it made it work. Thank you so much!

1 like

Please or to participate in this conversation.