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

TrentDPT's avatar

5.3 with XAMPP

So quick question. Ive been following along with Jeff, but using XAMPP for my localhost server to run the test sites off of. I notice that when he does an HREF he just has to put the word with a / in front...whereas I either have to type out the entire URL or have to use the url root with the curly brackets around.

Why is this?

0 likes
2 replies
jlrdw's avatar

I use 5.1, and I don't need any curly braces, for example here is a link to an image

echo "<td><a href=\"upload/$tpic\" target=\"_blank\"><img width=\"80\" border=\"0\" src = \"upload/$tpic\"></a></td>";

notice the upload/$tpic works. Just learn how to resolve you paths properly. I don't use blade. And I use bitnami wampstack.

lindstrom's avatar

It's not a XAMPP issue. It's that if you precede the path with a "/" it will make the URL relative to the root of your project. Whereas if you don't prefix with "/", it will be relative to the current path.

For example, if you are at http://some.dev/directory

A link to:
<a href-"/upload">Upload</a>

Would resolve to:
http://some.dev/upload

A link to:
<a href="upload">Upload</a>

Would resolve to:
http://some.dev/directory/upload

If you are talking about something else, please provide an example.

In the future, you will find the url(), action() and route() helpers useful, but they are not necessary. Just get your paths and routes correct for now.

Please or to participate in this conversation.