我想改变元内容="根据标题"

时间:2017-05-24 07:33:50

标签: javascript html meta

这是我的代码

当页面刷新时,我想根据那个改变元内容。 根据这个,制作一个代码&发表评论



<html>
<head>
<meta property="fb:app_id" content="366632706686339" />
<meta name="twitter:card" value="summary"> 
<meta property="og:title" content="?></title>" />
<meta http-equiv="refresh" content="0">
<title><?php

$titles = array();

$titles[] = "Possible Title 1";
$titles[] = "Possible Title 2";
$titles[] = "Etc. Etc.";

 srand ((float) microtime() * 10000000); // Seed the random number generator

echo $titles[array_rand($titles)]; // Pick a random item from the array and output it
?></title>
</head>
<body>
</body>
</html>
&#13;
&#13;
&#13;

3 个答案:

答案 0 :(得分:0)

检查并告诉我是否有效。

<html>
<head>
<meta property="fb:app_id" content="366632706686339" />
<meta name="twitter:card" value="summary">     
<title><?php

$titles = array();

$titles[] = "Possible Title 1";
$titles[] = "Possible Title 2";
$titles[] = "Etc. Etc.";

 srand ((float) microtime() * 10000000); // Seed the random number generator

echo $titles[array_rand($titles)]; // Pick a random item from the array and output it
?></title>
<meta property="og:title" content="<?= $titles[array_rand($titles)] ?>" />
</head>
<body>
</body>
</html>

答案 1 :(得分:0)

使用此:

<meta property="og:title" content="<?=$titles[0]?>" />

答案 2 :(得分:0)

使用此代码(我已为您编辑代码)

<?php

        $titles = array();

        $titles[] = "Possible Title 1";
        $titles[] = "Possible Title 2";
        $titles[] = "Etc. Etc.";

         srand ((float) microtime() * 10000000); // Seed the random number generator

        $titles[array_rand($titles)]; // Pick a random item from the array and output it
        ?>



        <html>
        <head>
        <meta property="fb:app_id" content="366632706686339" />
        <meta name="twitter:card" value="summary"> 
        <meta property="og:title" content="<?=$titles[array_rand($titles)];?>" />
        <meta http-equiv="refresh" content="0">
        <title><?=$titles[array_rand($titles)];?></title>
        </head>
        <body>
        </body>
        </html>