title: using php in js function (external .js file)
body: <p>I have a jakosc-powietrza.js file containing functions like this:</p>
  
  <pre><code>var combo1 = document.getElementById('S0_Data');
  function test() {
      var dzien = combo1.value.trim();
      alert("Wybrano " + dzien);
   };
  function render_test() {
      var test1 = &lt;?php echo x; ?&gt;;
  
      var chart = new CanvasJS.Chart("chartContainer", {
              theme: "light2",
              animationEnabled: true,
              title: {
                  text: "Pomiar parametrÃ³w powietrza",
                  fontSize: 25
                      },
              axisX: {
                  title: "Czas",
                  titleFontSize: 15,
                  labelAngle: -90,
                  intervalType: "hour",
                  interval:55
                     },
              axisY: {
                  title: "oC/%",
                  titleFontSize: 15
                     },
              axisY2: {
                  title: "ppm/ppb",
                  titleFontSize: 15
                     },
              data: [
                    {
                  type: "line",
                  color: "red",
                  name: "Temperatura",
                  showInLegend: true,
                  dataPoints: &lt;?php echo json_encode($data_points, JSON_NUMERIC_CHECK); ?&gt;
                    },
                    {
                  type: "line",
                  color: "green",
                  name: "WilgotnoÅ›Ä‡",
                  showInLegend: true,
                  dataPoints: &lt;?php echo json_encode($data_points2, JSON_NUMERIC_CHECK); ?&gt;
                    },
                    {
                  type: "line",
                  color: "blue",
                  name: "eCO2",
                  axisYType: "secondary",
                  showInLegend: true,
                  dataPoints: &lt;?php echo json_encode($data_points3, JSON_NUMERIC_CHECK); ?&gt;
                    },
                    {
                  type: "line",
                  color: "yellow",
                  name: "TVOC",
                  axisYType: "secondary",
                  showInLegend: true,
                  dataPoints: &lt;?php echo json_encode($data_points4, JSON_NUMERIC_CHECK); ?&gt;
                    }
                    ]
          });
          chart.render();
  };
  combo1.addEventListener('change', render_test, false);
  </code></pre>
  
  <p>I include it into test.php file like this:</p>
  
  <pre><code>&lt;script type="text/javascript" src="js/jakosc-powietrza.js"&gt;&lt;/script&gt;
  </code></pre>
  
  <p>When I open test.php file using browser I got the following error in web console:</p>
  
  <p><em>SyntaxError: expected expression, got '&lt;'</em></p>
  
  <p>...and it points to this:</p>
  
  <pre><code>var test1 = &lt;?php echo x; ?&gt;;
  </code></pre>
  
  <p>Any pointers what I am doing wrong?</p>