[英]How can i concatenate the id and the # and put it in the href tag? This code is not working for me
$temporaryID = $row->id; //data row ID from table
$concat = "#".$temporaryID; //concatenate it for href
if($x % 2==1){
echo '<li class="featuredNews-li" href="$concat" data-toggle="tab">';
}
?>
Trying to concatenate the # with the data id to put it the href tag. 尝试将#与数据ID串联起来,将其放入href标记。
您需要将字符串用双引号引起来(并在字符串内转义)
echo "<li class=\"featuredNews-li\" href=\"$concat\" data-toggle=\"tab\">";
Change 更改
$temporaryID = $row->id;
$concat = "#".$temporaryID;
if($x % 2==1){
echo '<li class="featuredNews-li" href="$concat" data-toggle="tab">';
}
To: 至:
eliminating $concat
消除
$concat
$temporaryID = '#' . $row->id;
if($x & 1){
echo "<li class=\"featuredNews-li\" href=\"$temporaryID\" data-toggle=\"tab\">";
}
I prefer $x & 1
rather than $x % 2==1
because the AND function is a single micro instruction. 我更喜欢
$x & 1
而不是$x % 2==1
因为AND函数是单个微指令。 Your method is a math function and comparison. 您的方法是数学函数和比较。
But that is here nor there. 但这不存在。 Double quoted string with escaped double quote within the sting.
用双引号引起的字符串,在字符串中使用转义的双引号。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.