【发布时间】:2015-06-21 06:18:35
【问题描述】:
我想在 wordpress 的 header.php 和 footer.php 中使用相同的随机生成值。我试过这个函数来随机生成值:
function randValue() {
$randCheaters = substr(md5(microtime()),rand(0,26),5);
return $randCheaters;
}
在 header.php 中我使用了类似的东西
<header id="<? echo randValue(); ?>">
在footer.php中我使用了这个
<footer id="<? echo randValue(); ?>">
问题是它在页脚和页眉中生成不同的值,我怎样才能在两个地方获得相同的值。
【问题讨论】:
-
只调用一次函数,存储返回值,回显两次
-
嘿@Dagon你能给我一个例子我该怎么做。
-
一个专业开发人员应该可以解决这个问题:)
-
@Dagon 非常好,非常正确 ;-)
标签: php wordpress random dynamically-generated