我想在像...这样的页面中显示元标记。
<meta property="og:title" content="Hi Admin, How are you" />
<meta property="og:image" content="http://example.com/hiadmin.jpg" />
和
<meta property="og:title" content="Hi User, How are you" />
<meta property="og:image" content="http://example.com/user.jpg" />
问题 -
我想随机显示元标记,如..
你好管理员,你好吗(10次中有9次) 嗨用户,你好吗(10次中有1次)
我该怎么做?完全糊涂了:/
答案 0 :(得分:1)
您正在寻找的是:
<?php
if (rand(1, 10) == 1){
?>
<meta property="og:title" content="Hi User, How are you" />
<meta property="og:image" content="http://example.com/user.jpg" />
<?php
} else {?>
<meta property="og:title" content="Hi Admin, How are you" />
<meta property="og:image" content="http://example.com/hiadmin.jpg" />
<?php }?>