2016-07-06 10 views
-2

HTML aタグにPHPコード(動的コンテンツ用)を使用できますか?HTMLタグにPHPを追加する

私はこのようなコードをしました:

<ul> 
       <li> 
      <a href="#" class="offset" title="The sun escaping the horizon"> 
       <img src="img/2.jpg" alt="" class="imagequery"> 
      </a> 
     </li> 
      </ul> 

私はタグにタイトルとして、私のPHPコードを配置する必要があります。 可能ですか?

答えて

0
<?php $title = "My Test Title"; ?> 
<ul> 
      <li> 
     <a href="#" class="offset" title="<?php echo htmlspecialchars($title); ?>"> 
      <img src="img/2.jpg" alt="" class="imagequery"> 
     </a> 
    </li> 
     </ul> 
+0

タイトルは動的です。公開された投稿から来たものは静的なものではありません。 – djhru

2
//yes it is possible 
    <ul> 
    <li> 
    <?php $title="The sun escaping the horizon";?> 
    <a href="#" class="offset" title="<?php echo $title;?>"> 
    <img src="img/2.jpg" alt="" class="imagequery"> 
    </a> 
    </li> 
    </ul> 
関連する問題