title: Using php variable in a block of code implemented with jquery before()
body: <p>I already asked this question and it has been marked as duplicate by the first person who came and thought that I asked how to find the current url using javascript. <strong>This is not my question !</strong></p>
  
  <p>I'm wondering if this is possible, right now I can't seem to be able to make it work but I would be glad to hear it can work.</p>
  
  <p>So first, I have this random page in which I pasted a script tag to load my js file, and a php variable getting my current url : </p>
  
  <pre><code>&lt;script src="/plugin-cookies/front-cookies.js" type="text/javascript"&gt;&lt;/script&gt;
  &lt;?php $currentlink = 'http://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']; ?&gt;
  </code></pre>
  
  <p>Then, in my js file I have a jquery function to append the wanted files to the page :</p>
  
  <pre><code>$(document).ready(function(){
  $.get("cookies-include.php", function(data){
      $('footer').last().before(data);
  });
  $.get("cookies-margin.php", function(data){
      $('head').append(data);
  });
  });
  </code></pre>
  
  <p>Finally, in my "cookies-include.php" file, I want to use this "$currentlink" variable (I can't set it in cookies-include.php because it gives me the link to itself...).</p>
  
  <p>Here is th code I want to use in cookies-include.php (which is implemented in the page via jquery) :</p>
  
  <pre><code>global $currentlink;
  if($currentlink == $setlink){
      do stuff...
  } else {
      some other stuff...
  }
  </code></pre>
  
  <p>I tried to "echo" $currentlink but I don't get anything.</p>
  
  <p>What I don't get is that the $currentlink variable is set before the js function starts, so shouldn't it be fine ?</p>
  
  <p>So to sum it up :</p>
  
  <p>1 - I create my php variable and call my js file in a page</p>
  
  <p>2 - My js file implements a second php file inside the page using before()</p>
  
  <p>3 - I want the php file that I implemented in the page to use the variable that was created in the first point.</p>