Passing js variable into php string

javascript, php

Solution

Here's an example using jquery.

Javascript:

<script type="text/javascript">
  var js_variable = appl+goog+fb+mfst+nflx;
  $.post("/somephp.php", {ticker: js_variable}, function(data) {
    // returned from php
  });
</script>

PHP:

 <?php
   $ticker = $_POST['ticker'];
   $file = file_get_contents("http://finance.yahoo.com/d/quotes.csv?s=$ticker&f=soac1p2ghjkj1re");
 ?>

Problem

I need a little bit of help im trying to page a js variable into a url thats being parsed in php using file_get_contents. Im not sure where to start to do that. ``` <script type="text/javascript"> var js_variable = appl+goog+fb+mfst+nflx; </script> <?php $ticker = js_varable_here; $file = file_get_contents('http://finance.yahoo.com/d/quotes.csv?s=$ticker&f=soac1p2ghjkj1re'); ?> ``` any advice is appreciated, like i said im in the dark on this one.

Original source