javascript window.open里面的php代码

I want to print some javascript in a php script to open a link in a new window:

<?php
//php script
$link='http://mylink';
print('<script type="text/javascript">');
print('window.open(' . $link . ', "Link","width=600,height=800")');
print('</script>');
?>

But this code didnt work. Any idea how to open a new window with php printed script?

You're missing some quotes. Replace:

print('window.open(' . $link . ', "Link","width=600,height=800")');

With:

print('window.open("' . $link . '", "Link","width=600,height=800")');
                   ^             ^

In JavaScript, this line will result in:

window.open("http://mylink", "Link","width=600,height=800")

You need the double quotes there to open / close the string.