将php变量传递给外部javascript [重复]

This question already has an answer here:

How can I pass the php variables into an external javascript file? I found a lot of questions regarding this but I can't figure it out anyhow.

In the HTML file I have this link

<script type="text/javascript" src="myscript.php"></script>

This is the myscript.php file that I have been trying to output as a javascript file:

<?
Header("content-type: text/javascript");
?>

$(document).ready(function() {

$("#validate_form").validate({
    rules: {
        page_title: "required",
        seo_url: "required"
    },

    messages: {
        page_title: "<?=$page_title?>",
        seo_url: "<?=$seo_url?>"
    }
 }); 
});
</div>

Append them using a query string:

<script type="text/javascript" src="myscript.php?page_title=whatever&seo_url=whatever"></script>

<?
Header("content-type: text/javascript");
?>

$(document).ready(function() {

$("#validate_form").validate({
    rules: {
        page_title: "required",
        seo_url: "required"
    },

    messages: {
        page_title: "<?=$_GET['page_title'];?>",
        seo_url: "<?=$_GET['seo_url'];?>"
    }
 }); 
});