【发布时间】:2013-11-19 13:13:40
【问题描述】:
我在项目的不同页面中使用 php echo 来更新每天都在变化的百分比值。这个值可以是负数也可以是正数。
这是我的代码:
<i class="icon-thumbs-up"><strong> <?php $file = file('include.txt');echo $file[n]; ?></strong></i>
我正在使用带有 Bootstrap 模板的 FontAwesome 图标。像这样一切正常。
现在,如果百分比是负数,我想使用 class="icon-thumbs-down" 而不是 class="icon-thumbs-up"。
我已经尝试过使用
<i class="<?php $file = file('include.txt');echo $file[n]; ?>"><strong> <?php $file = file('include.txt');echo $file[13]; ?></strong></i>
为了在所有页面上更改它。
但是,这不起作用。感谢您的任何提示!
澄清一下:
<i class="icon-thumbs-up"><strong> <?php $file = file('include.txt');echo $file[0]; ?></strong></i>
include.text 的内容:第 1 行的 0.58% -> 一切正常。我竖起大拇指,旁边的值为 0.58%。
现在我尝试更改为:
<i class="<?php $file = file('include.txt');echo $file[1]; ?>"><strong> <?php $file = file('include.txt');echo $file[0]; ?></strong></i>
include.text 的内容:第 1 行为 0.58%,第 2 行为 icon-thumbs-up。(我想每天在 include.txt 中将其更改为 icon-thumbs-up 或 icon-thumbs -down,取决于第 1 行的值。)
【问题讨论】:
-
不清楚你想听什么。你的代码试图做什么?换句话说,预期的输出是什么?另外,
include.txt是什么?