【问题标题】:Php code to randomly pick links And Openphp代码随机选择链接并打开
【发布时间】:2018-07-15 00:04:47
【问题描述】:

我是 PHP 新手。加载脚本时,我有点需要代码在浏览器中打开链接。 下面是我的代码。

<?php
$links = array_open("https://stackoverflow.com/",
                    "https://outlook.office.com/",
                    "https://www.protectedtext.com/", 
                    "https://www.adobe.com/",
                    "https://www.linkedin.com");
echo $links[array_rand($links)];
?>

【问题讨论】:

  • 您能否详细说明您的问题是什么?
  • 已经得到答案

标签: php php-7


【解决方案1】:

您好,将array_open 更改为array

<?php
$links = array("https://stackoverflow.com/", "https://outlook.office.com/", "https://www.protectedtext.com/", "https://www.adobe.com/", "https://www.linkedin.com");
echo $links[array_rand($links)];
?>

如果你想将浏览器发送到链接,你会发送一个像这样的位置标头......

<?php
$links = array("https://stackoverflow.com/", "https://outlook.office.com/", "https://www.protectedtext.com/", "https://www.adobe.com/", "https://www.linkedin.com");
header('Location: ' . $links[array_rand($links)]);
exit;
?>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-10-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-03-09
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多