Organising code that includes php and javascript files
<p>I have a website where I am including a php library file and a javascript library file.  I have condensed the problem to the following files:</p>

<p><strong>index.php</strong></p>

<pre><code>&lt;?php
  include('constants.php');
?&gt;
&lt;html&gt;
  &lt;head&gt;
    &lt;script type="text/javascript" src="lib.js"&gt;&lt;/script&gt;
  &lt;/head&gt;
  &lt;body onload="javascript:show_const_1('&lt;?php echo(CONST_TEXT); ?&gt;');
                           show_const_2();"&gt;
    Some text here
  &lt;/body&gt;
&lt;/html&gt;
</code></pre>

<p><strong>constants.php</strong></p>

<pre><code>&lt;?php
  define('CONST_TEXT', 'Hello World');
?&gt;
</code></pre>

<p><strong>lib.js</strong></p>

<pre><code>function show_const_1(string)
{
  alert(string);
}

function show_const_2()
{
  alert('&lt;?php echo(CONST_TEXT); ?&gt;');
}
</code></pre>

<p>The result is that when the page loads I get two message boxes.  The first says "Hello World" and the second says "&lt;?php echo(CONST_TEXT); ?>".  The first javascript method does what I want it to, but I will be using the function in many places across the site and so ideally I don't want to have to pass the constant as a parameter every time.</p>

<p>Is there a good way to rearrange the code to make the second javascript method work?</p>
