Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/226.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在HTML标记中添加PHP_Php_Html_Tags - Fatal编程技术网

在HTML标记中添加PHP

在HTML标记中添加PHP,php,html,tags,Php,Html,Tags,我可以在HTMLa标记中使用PHP代码(用于动态内容)吗 我有这样一个代码: <ul> <li> <a href="#" class="offset" title="The sun escaping the horizon"> <img src="img/2.jpg" alt="" class="imagequery"> </a>

我可以在HTML
a
标记中使用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代码作为标题放在标记中。 可能吗?


<?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>
//是的,这是可能的

你的意思是:为什么不尝试一下,看看会发生什么?标题是动态的,它来自已发表的文章,而不是静态的注释。
    //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>