phpsrand
發布時間: 2025-08-07 08:52:29
1. 我有一組微信號,每次刷新頁面,隨機顯示一個微信號,怎樣用php實現
php後台代碼(命名為:houtai.php):
<?php
srand ((float) microtime() * 10000000);
$input = array ("wx1", "wx2", "wx3", "wx3");
$rand_keys = array_rand ($input);
//print $input[$rand_keys];
?>
前台代碼(在前台展示頁面,例如:index.php):
<span id="wxzs"><?php require_once 'houtai.php'; echo "$input[$rand_keys]";?></span>
主要利用隨機數原理,可以參考這個網址:http://www.jb51.net/article/84856.htm
熱點內容
