Html inside php, including javascript
<p>I am trying to do following things:</p>

<p>in my index.php I have:</p>

<pre><code>$GLOBALS['MAINURL'] = "http://localhost/myapp/";
</code></pre>

<p>in the function in which I am generating the page header:</p>

<pre><code>public function header() {
     echo"&lt;!DOCTYPE html&gt;
     &lt;html lang='en'&gt;
     &lt;head&gt;
        &lt;meta charset='utf-8'&gt;
        &lt;meta http-equiv='X-UA-Compatible' content='IE=edge'&gt;
        &lt;meta name='viewport' content='width=device-width, initial-scale=1'&gt;

        &lt;!-- Bootstrap themes stuff here --&gt;

        &lt;title&gt;My app title&lt;/title&gt;    

        &lt;script type='text/javascript' src='https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js'&gt;&lt;/script&gt;
        &lt;script type='text/javascript' src='https://ajax.googleapis.com/ajax/libs/jqueryui/1.9.1/jquery-ui.min.js'&gt;&lt;/script&gt;
        &lt;script type='text/javascript' src='" . $GLOBALS['MAINURL'] . "Common/main.js'&gt;&lt;/script&gt;
      &lt;/head&gt;
      &lt;body role='document'&gt;";
}
</code></pre>

<p>And footer:</p>

<pre><code>public function footer() {
     echo "                
        &lt;footer class='footer'&gt;
            &lt;div class='container'&gt;
                &lt;p class='text-muted'&gt;abc&lt;/p&gt;
            &lt;/div&gt;
        &lt;/footer&gt;

        &lt;script src='https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js'&gt;&lt;/script&gt;
        &lt;script src='". $GLOBALS['MAINURL'] . "Common/js/bootstrap.min.js'&gt;&lt;/script&gt;
        &lt;script src='". $GLOBALS['MAINURL'] . "Common/js/docs.min.js'&gt; ";   
}
</code></pre>

<p>The problem is in concatenating "MAINURL" with the rest of the path for bootstrap.min.js, docs.min.js and main.js (even though they are correct - I echoed them). When starting the app I have following error in the browser's console:</p>

<p><em>main.js:2 Uncaught SyntaxError: Unexpected token &lt;</em></p>

<p><em>bootstrap.min.js:2 Uncaught SyntaxError: Unexpected token &lt;</em></p>

<p><em>docs.min.js:2 Uncaught SyntaxError: Unexpected token &lt;</em> </p>

<p>It doesn't have a problem when I set </p>

<pre><code>$GLOBALS['MAINURL'] = "http://localhost/"; 
</code></pre>

<ul>
<li>without "myapp/". But then the resources are not found. Do you have any idea how to deal with it? I would rather stay with the directory structure and <em>myapp</em> folder. </li>
</ul>