亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

使用 PHP 隨機重定向

使用 PHP 隨機重定向

PHP
尚方寶劍之說 2022-09-24 17:19:13
我試圖隨機重定向2 URL,但它不起作用。我的代碼<?php$urls=readStack();if(empty($urls)) {    $urls = shuffle(array('https://domain1.com', 'https://domain2.com'));     $url=array_pop($urls);    storeStack($urls);    header('Location:' .$url); ?>幫助如何解決這個問題?
查看完整描述

1 回答

?
慕婉清6462132

TA貢獻1804條經驗 獲得超2個贊

我不知道是什么,但你可能想要這樣的東西readStack()storeStack()


$arr = array('https://domain1.com', 'https://domain2.com');

shuffle($arr); // This returns a boolean and the array is modified inside the function so just pass in the array

$url=array_pop($arr); // Pop the top most element from the array and store into $url

header("Location: $url");

僅該代碼就為您提供了來自這兩個的隨機URL


查看完整回答
反對 回復 2022-09-24
  • 1 回答
  • 0 關注
  • 74 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號