Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7834077
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T13:03:14+00:00 2026-06-02T13:03:14+00:00

I wish to write the response of hitting a given url into the href

  • 0

I wish to write the response of hitting a given url into the href attribute of an anchor tag using PHP. How can I do this?

Here’s an example of what I excpect to happen

mylink.com/getdoc?name=documentA

returns a string as a response:

mylink.com/document2012-03-15.pdf

I need to write this response (using PHP into the href attribute as shown below:

<a href="mylink.com/document2012-03-15.pdf"> Open Document A </a>

(so the above will be the final source of my page.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T13:03:17+00:00Added an answer on June 2, 2026 at 1:03 pm

    I think there are a few ways to do what you want. Not all of them will work exactly as you ask for, but the end result should be the same.

    Solution one

    My first possible solution was already posted by @shanethehat. You could use file_get_contents to call your PHP script via HTTP and get the response.

    Solution two

    Another possible solution was suggested in the comments of the post by @YourCommonSense. You could simply include the getdoc script in the PHP script that is generating your HTML file, like this:

    $_GET["name"] = "documentA";
    echo "<a href=\"". include("getdoc.php") ."\"> Open Document A </a>";
    

    Solution three

    Or you could change the way the getdoc script works. You could use a script more like this:

    header("Content-type:application/pdf");
    header("Content-Disposition:attachment; filename=\"{$_GET["name"]}\"");
    readfile($_GET["name"]);
    

    And you keep your link like this: <a href="mylink.com/getdoc.php?name=documentA"> Open Document A </a>. When getdoc.php is called, it will get the specified file and start a file download.

    NOTE: you should probably do some input sanitization with this method (removing slashes, making sure the file ends in .pdf, etc) to make sure someone doesn’t try to get a file they’re not allowed to get.

    That’s all I’m coming up with at the moment. There might be a more clever way to do it, but hopefully one of these solutions will do it for you. I would try solution 2 or 3 first, and if they don’t work out for you, then go with solution 1.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How can I do this? I just wish to write something like while(true) {
I am using Qt and wish to write a class that will perform some
I wish to be able to generate URL variables like this: http://example.com/195yq http://example.com/195yp http://example.com/195yg
I wish to write a class similar to the dictionary class where I can
I wish to write a function that operates on any value that can be
I wish to write a function which I can add to my .vimrc file
I'm using constructor injection for the first time and wish to write my code
I wish to write a C# WinForms application that can play a WAV file.
I wish to write a simple javascript function that toggles the visibility of a
I wish to write a reusable library for querying against AD with LDAP. I'm

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.