Jump to content

transforming href attribute to URL


Case-Sensitive

Recommended Posts

Hi

Im trying to turn a href attribute from a link <a> element into a url.

The problem Im having is that the link <a href="index.html">home</a>, just stores the filename, so when I try and use curl to get the contents from the page it gives a "unresolved host error". Which is because of the value in  the fref is not a well formed url string.

Is there a way of getting the servers path e.g http://localhost/site so i can prefix it onto the href attribute before passing it to the curl function.

Ive tried the following, but it does not give a url, it does give working directories and stuff

print("<pre>");
print_r($_SERVER);
print("</pre>");

Any help or ideas would be great

Cheers
Link to comment
https://forums.phpfreaks.com/topic/34577-transforming-href-attribute-to-url/
Share on other sites

Im guessing no one replied because of the stupidness of this post. I just realised how Stupid it was (not me)! After thinking about it, it was a useless post, which created more server processing thus adding additional carbon emissions to the atmosphere (apologies to your children)

If all sites start at root, all i had to do was prefix the url (that was given at the beginning) of the site to the href attribute:
[code]
$url_to_test="http://www.example.com/";
$href = "about.html";
[/code]

then concatenate the strings, so it would give a well formed url: "http://www.example.com/about.html":
[code]$url_to_test.$href;[/code]

Sorry Guys

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.