title: Set a JavaScript variable equal to a PHP variable
body: <p>I downloaded someone's project on GitHub that enabled Facebook users to send Bitcoin to each other. He abandoned development a year ago, and I want to build my own application but I am currently looking at his code and trying to get my development environment set up.</p>
  
  <p>I understand PHP kinda, that its meant for server side scripting and that JavaScript is executed on a client machine (all in the browser, and Node.js is a server side framework)</p>
  
  <p>Anyways, he's doing something peculiar, and its producing an error.</p>
  
  <p>The directory structure is as follows:</p>
  
  <pre><code>inc/
    init.php
    app.php
    btc.php
  index.php
  settings.php
  </code></pre>
  
  <p>With many more files but the above will suffice I think.<br>
  So I run the command "php -S localhost:8000" and it starts a server</p>
  
  <p>I go to localhost and once the page renders I get these errors in the terminal:</p>
  
  <pre><code>[Sat Apr 12 02:23:11 2014] PHP Notice:  Undefined variable: app_url in /home/arthur/projects/bfb/index.php on line 21
  
  [Sat Apr 12 02:23:11 2014] PHP Notice:  Undefined variable: callback_url in /home/arthur/projects/bfb/index.php on line 22
  
  [Sat Apr 12 02:23:11 2014] PHP Fatal error:  Call to undefined function get_x_rates() in /home/arthur/projects/bfb/index.php on line 23
  
  [Sat Apr 12 02:23:11 2014] 127.0.0.1:59511 [200]: / - Call to undefined function get_x_rates() in /home/arthur/projects/bfb/index.php on line 23
  
  [Sat Apr 12 02:23:11 2014] 127.0.0.1:59512 [200]: /stylesheets/reset.css
  
  [Sat Apr 12 02:23:11 2014] 127.0.0.1:59513 [200]: /stylesheets/btc.css
  
  [Sat Apr 12 02:23:11 2014] 127.0.0.1:59514 [200]: /javascript/chosen.css
  
  [Sat Apr 12 02:23:21 2014] 127.0.0.1:59515 Invalid request (Unexpected EOF)
  
  [Sat Apr 12 02:23:21 2014] 127.0.0.1:59516 Invalid request (Unexpected EOF)
  </code></pre>
  
  <p>The index.php file has the following general structure:</p>
  
  <pre><code>&lt;?php
  //error_reporting(E_ALL);
  //ini_set("display_errors", 1);
  
  require 'settings.php';
  
  require 'inc/btc.php';
  require 'inc/app.php';
  
  require 'inc/init.php';
  
  ?&gt;
  &lt;!DOCTYPE html&gt;
  &lt;html xmlns:fb="http://www.facebook.com/2008/fbml"&gt;
      &lt;head&gt;
          &lt;meta charset="utf-8" /&gt;
          &lt;title&gt;Bitcoin Transactions&lt;/title&gt;
          &lt;link rel="stylesheet" href="stylesheets/reset.css" type="text/css" /&gt;
          &lt;link rel="stylesheet" href="stylesheets/btc.css" type="text/css" /&gt;
          &lt;link rel="stylesheet" href="javascript/chosen.css" type="text/css" /&gt;
          &lt;script&gt;var appurl='&lt;?=$app_url?&gt;',
                      hosturl='&lt;?=$callback_url?&gt;',
                      rates=&lt;?=get_x_rates()?&gt;;&lt;/script&gt;
          &lt;script type="text/javascript" src="javascript/jquery-1.7.1.min.js"&gt;    &lt;/script&gt;
      &lt;script type="text/javascript" src="javascript/chosen.jquery.min.js"&gt;&lt;/script&gt;
      &lt;script type="text/javascript" src="javascript/btc.js"&gt;&lt;/script&gt;
  &lt;/head&gt;
  
  &lt;body&gt;
   ....
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>Since he's loading the PHP files in the beginning of the html file, why can't it see the variables I've defined in this settings.php file:</p>
  
  <pre><code>&lt;?
  $bucket_addr='-taken-out-for-Stack-Overflow';
  $callback_url='https://super-lame-name-1231232.herokuapp.com/';
  $app_url='https://apps.facebook.com/c------------------n';
  $blockchain_guid="xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx";
  $blockchain_pw="xxxxxxxxxxxxxxxx";
  $fb_settings=array(
    'appId'  =&gt; 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
    'secret' =&gt; 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
  );
  $fb_tx_fee=10000; //in satoshi (0.0001 BTC)
  $btc_tx_fee=50000; //in satoshi (0.0005 BTC)
  $tx_per_page=10;
  $revert_duration="60 days";
  </code></pre>
  
  <p>Thanks for any help!!</p>