php - 如何在 Html div 中使用 php 变量值

标签 php html twitter-bootstrap

我有一个全局 php 变量 $similarity; 并且我通过以下代码获得了这个 Bootstrap 进度条:

<div class="progress progress-striped active">
<div class="bar" style="width: 74%;"></div> 
</div>

宽度(在本例中为 74%)决定了进度条看起来被归档的量。 我想要做的是使用 $similarity 的值代替 74。这样进度条将根据变量的值填充。

我该怎么做?

最佳答案

你可以这样做

<div class="bar" style="width: <?php echo $similarity; ?>%;">

但确保文件扩展名是.php

关于php - 如何在 Html div 中使用 php 变量值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14169507/

相关文章:

php - 如何使用 PHP 与 Instagram 共享链接和照片

php - Uncaught Error : Call to undefined function mysql_connect() - each time I run my php file it shows me this error

php - 在循环中每 2 个 div 包装时未关闭的 div

javascript - 使用 Javascript 添加 css 类的问题

html - 文本在 bootstrap 3 输入文本中不可见

html - Bootstrap - 手机上的小内容

php - Javascript 查找并滚动到文本

php - 我想在使用 php 创建的 HTML 表上每隔一行添加一个空行

javascript - 使用textarea自动扩展背景高度

html - Twitter Bootstrap 选项卡不工作 : when I click on them nothing happens