Sign up ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free.

This question already has an answer here:

I have a variable which stores the path of the file. I am using a pop up window to display that image. I am using following script

function newPopup(url) {
    popupWindow = window.open(
        url,'popUpWindow','height=700,width=800,left=10,top=10,resizable=yes,scrollbars=no,toolbar=no,menubar=no,location=no,directories=no,status=yes')

Using it as

echo '<td width="150"><a href="JavaScript:newPopup(\'ajax-loader.gif\');">ScreenShot</a></td>';

When I give the name not stored in variable as mentioned above, the script works fine. But when I try to give the variable $end_file, it is not working. I have tried following combinations

 echo '<td width="150"><a href="JavaScript:newPopup(\''.'$end_file'.'\');">ScreenShot</a></td>';
 echo '<td width="150"><a href="JavaScript:newPopup(\'{$end_file}\');">ScreenShot</a></td>';

But none seems to work

share|improve this question

marked as duplicate by Madara Uchiha php May 19 '14 at 15:25

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

    
are you using smarty? – Sumit Bijvani Mar 4 '13 at 7:32

3 Answers 3

echo '<td width="150"><a href="JavaScript:newPopup(\"'.$end_file.'\");">ScreenShot</a></td>';
share|improve this answer

You can simply do the following :

<?php
$x="PHP";
?>    
<script>alert("Hello from <?php echo $x;?>");</script>
share|improve this answer

Remove the quotes around '$end_file' in your first example and it should work.

echo '<td width="150"><a href="JavaScript:newPopup(\''.$end_file.'\');">ScreenShot</a></td>';

For the second example, I believe you have to use double-quotes for string-iterpolation to work.

echo "<td width='150'><a href='JavaScript:newPopup(\"$end_file\");'>ScreenShot</a></td>';
share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.