且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在HTML中使用PHP变量?

更新时间:2023-11-25 08:03:34

试试这个

 < a href =<?php echo $ pathimage。$ imagename;?> 
class =slide
title =
onclick =return hs.expand(this,$ K)>
< img src =<?php echo $ pathimage2。$ imagename;?>
alt =/>
< / a>


Below are the PHP variables I'd like to use in my HTML code:

var

$pathimage1="mydir/images/large/";

$pathimage2="mydir/images/thumb/";

$imagename="landscape.jpg";

$K="item1";

$row=180;

$colon=200;

how does one use these php variables in html code?

<td width=$row height= $colon >
<div class="classname">
<a href=$pathimage + $imagename 
 class="slide" 
 title="" 
 onclick="return hs.expand(this, $K)">
 <img src=$pathimage2 + $imagename  
 alt=""/>
     </a>
 </div>
 </td>

Try like this

<a href="<?php echo $pathimage.$imagename;?>" 
 class="slide" 
 title="" 
 onclick="return hs.expand(this, $K)">
 <img src="<?php echo $pathimage2.$imagename;?>"
     alt=""/>
</a>