Jump to content

printing php code


droidus

Recommended Posts

i am having trouble writing this code:

 

<a href='downloadFile.php?file=<?php echo $_FILES[file][name]?>'>

 

i always get confused when it comes to echoing/printing php code.  i tried closing with '" . php code...here . "', but it didn't seem to work.  the link goes to (when clicked on), ?file=<?php echo [name]?>

Link to comment
https://forums.phpfreaks.com/topic/242337-printing-php-code/
Share on other sites

print("</td>");
		print ("<td align='center'><input name='file[]' type='checkbox' value='$file' /></td>");
		print ("<td>" . date ('F d Y H:i:s.', filemtime($file)) . "</td>");
		print ("<td><a href='downloadFile.php?file=<?php echo $_FILES[file][name]?>'><img src='http://www.mysite.com/Images/icn_file_download.png' width='50' height='50' title='Download this file!' /></a></td>");
        }
}

Link to comment
https://forums.phpfreaks.com/topic/242337-printing-php-code/#findComment-1244632
Share on other sites

Thanks:

 

print "<td><a href='downloadFile.php?file=". $_FILES['file']['name'] . "'><img src='http://www.mysite.com/Images/icn_file_download.png' width='50' height='50' title='Download this file!' /></a></td>";

 

Is what you should be using. When you are echoing a variable inside of PHP code, you need to concatenate variables onto it (like I just showed you). If you are working out side of PHP, then you would use the echo like you had:

 

?>
<some html here>
<td><?php echo $var; ?></td>
<?php
// more php code
?>

 

Hopefully that makes sense to you.

Link to comment
https://forums.phpfreaks.com/topic/242337-printing-php-code/#findComment-1244633
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.