gpt4 book ai didi

php - 带有 php 函数的图像链接

转载 作者:行者123 更新时间:2023-11-28 14:42:55 26 4
gpt4 key购买 nike

我有一个关于函数的问题。

function &formatName($id, $name, $clanId, $clanSym, $clanCol)
{
static $cache = array();

if (!isset($cache[$name])) {
$cache[$name] = esc($name);

if ($id !== NULL) {
$cache[$name] = '<a href="' . esc('player_info.php?target=' . $id) .
'">' . $cache[$name] . '</a>';
} else {
$cache[$name] = "<s>{$cache[$name]}</s>";
}

if ($clanId !== NULL && $clanId != 0) {
$cache[$name] = "(<span style=\"color: #$clanCol;\">" .
htmlentities($clanSym) . "</span>) " . $cache[$name];
}
}

return $cache[$name];
}

//打印$player的可点击名称

function print_name($player)
{
global $db_name, $user_options;
static $cache = array();

if (!isset($cache[$player['login_name']])) {//this user not cached
$pQuery = mysql_query("select u.login_id, u.login_name, u.clan_id, u.clan_sym_color,u.clan_sym from ${db_name}_users u where u.login_id = '$player[login_id]'");
$player = mysql_fetch_assoc($pQuery);

$cache[$player['login_name']] = formatName($player['login_id'],
$player['login_name'], $player['clan_id'], $player['clan_sym'],
$player['clan_sym_color']);
}

return $cache[$player['login_name']];
}

上面的函数打印了一个带有玩家名字的链接。我想在链接上放置一张 table 或某种装饰背景。我有什么办法可以做到这一点?感谢您的阅读。

最佳答案

只需更改行:

$cache[$name] = '<a href="' . esc('player_info.php?target=' . $id) . '">' . $cache[$name] . '</a>';

$cache[$name] = '<span class="link-decorator">';
$cache[$name] .= '<a href="' . esc('player_info.php?target=' . $id) .
'">' . $cache[$name] . '</a>';
$cache[$name] .= '</span>';

然后您可以使用 CSS 为链接和周围的跨度设置样式:

span.link-decorator { border: 3px solid #789abc; }
span.link-decorator a { color: red; }
span.link-decorator a:hover { color: blue; }
span.link-decorator a:visited { color: green; }

关于php - 带有 php 函数的图像链接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5674790/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com