Using a variable inside an anchor tag?

Hi everyone

Is it possible to use a variable which holds a path in side an anchor tag? If so what would be the markup?

For instance:


<a href=<?php $docroot; ?> "/downloads/update/file"></a>

I don’t think that this markup is correct, but is it along the right lines?

Thanks

Move your opening quote to before your PHP, and get rid of the space, and you’ve got it.

One thing i noticed, before your $docroot variable add echo and it will work perfect after that.

Thanks for the quick replies :slight_smile:

Ok I used the correct markup, and the link appears in the url bar with the correct address but it wont open the download.

The strange thing is that I have my links setup like this, before adding the variable:

<a href="/download/update/file">Download</a>

When I click the link, it goes through to the error “page cannot be found” but the link in the url is correct. Is there something that I am totally missing here?

Thanks again

Honestly, it sounds like the link path is wrong. Double—OK, triple—check that it’s the right path. The PHP gets processed before the page gets to the browser, so as far as the browser is concerned, the page was hard-coded from the start.

well it strikes me that your URL has no file extension on it… is it a directory?

Hi ralph.m

I have double and tripled checked, it is very strange and at this moment I can’t see why this wont work! I will do some more checking!

StarLion: The live link does have an extension on the end, I just didn’t put it on the example, which was a bit silly of me really!

Ok. I have just created a new folder, and moved my files for download from the original folder, and they work fine now. So it Looks like there might have been an issue with the main folder that I uploaded yesterday.

Thanks to everyone for taking the time to reply:D