Looking closer at the second example (sorry I'm drunk) - you tried to use the <script> tag - the script tag will work for client side scripts - not server side script. However as an interesting twist you can use php to auto generate scripts for you! This is useful when you have some arrays that you want to generate in DOM.
example generatejavascript.php
<?php
$arValues = array(
"small" => 1,
"medium" => 5,
"big" => 10
);
echo "var arLookup = new Object;";
while (list($strKey, $strValue) = @each($arValues))
{
echo "arLookup[{$strKey}] = '{$strValue}';";
}
?>
and in your html page you would say
<html>
<body>
<script src="http://foo.bar.com/generatejavascript.php"></script>
</body>
</html>
This is not a good idea if the data changes often because remember that browsers tend to cache scripts!