How to automatically insert a link from a page written in php to the html page code?
  • one
    What is echo "<a> </a>"? - Rules
  • In a sense, the link is originally taken from the browser line and inserted into the php document. Next, I need this link to automatically appear in the code page <a> </a>. I am creating an affiliate site, and so this whole idea is that from one site a lot of partners can promote their affiliate links. - Natalya
  • To be honest, I did not understand the essence. I will answer that understood. You can do JavaScript. Through innerHtml , on every page there will be this link. - koko
  • And you can in more detail, where to get it then javascript, how to write it? - Natalya
  • In general, like this: <div id = 'sslika'> Your link </ div> In the javascript for a single page, insert a script ( <script type = 'text/javascript' src = 'sample.js'> ). Then document.getElementById('ssilka').innerHTML = 'tvoya ssilka'; Well, if there should be a lot of references, it is different. I do not know if it helped or not. - koko

1 answer 1

If I understand the question correctly, then look at the $ _SERVER array . For example for example.com/some/script.php :

 echo $_SERVER['HTTP_HOST']; // выведет example.com echo $_SERVER['REQUEST_URI']; // выведет /some/script.php