doucang8303 2017-06-15 12:00
浏览 22

随机显示2个META标签

I want to Show meta tag like in a page like..

<meta property="og:title" content="Hi Admin, How are you" />
<meta property="og:image" content="http://example.com/hiadmin.jpg" />

and

<meta property="og:title" content="Hi User, How are you" />
<meta property="og:image" content="http://example.com/user.jpg" />

The Issue -

I want to Show meta tag randomly like..

Hi Admin, How are you (9 out of 10 times) Hi User, How are you (1 Out of 10 times)

how can i do this? totally confused :/

  • 写回答

1条回答 默认 最新

  • dongyao5843 2017-06-15 12:04
    关注

    What you are looking for is something like:

    <?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 }?>
    
    评论

报告相同问题?

悬赏问题

  • ¥15 vscode的问题提问
  • ¥50 切换TabTip键盘的输入法
  • ¥15 可否在不同线程中调用封装数据库操作的类
  • ¥15 微带串馈天线阵列每个阵元宽度计算
  • ¥15 keil的map文件中Image component sizes各项意思
  • ¥20 求个正点原子stm32f407开发版的贪吃蛇游戏
  • ¥15 划分vlan后,链路不通了?
  • ¥20 求各位懂行的人,注册表能不能看到usb使用得具体信息,干了什么,传输了什么数据
  • ¥15 Vue3 大型图片数据拖动排序
  • ¥15 Centos / PETGEM