absolute path source php
<p>This is maybe just a trivial question, but I don't really know what is the best practice to include, says javascript, img, or css using absolute path</p>

<p>What I am really using right now is using the code like this</p>

<pre><code>&lt;?php
$prefix = '//';
$rootFolder = $prefix . $_SERVER['HTTP_HOST'];
?&gt;
</code></pre>

<p>so then when i want to include something like jquery, I would just type the code like this</p>

<pre><code>&lt;script type="text/javascript" src="&lt;?php echo $rootFolder ?&gt;/jquery-1.7.1.min.js"&gt;&lt;/script&gt;
</code></pre>

<p>is this good enough? Or should I modify the prefix to "http://" or maybe there is some better way using another superglobal variable and such?</p>

<p>thanks in advance :)</p>
