Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/262.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用php随机功能生成文件名_Php_Random - Fatal编程技术网

使用php随机功能生成文件名

使用php随机功能生成文件名,php,random,Php,Random,我想随机选择在侧面板中使用的html 我需要一个php调用来用随机文件名填充变量 文件名为Righname_x.html,其中x是随机数(应介于1-5之间) 如何生成要存储在变量中的文件名 $filename = 'rightname_' . mt_rand(1,5) . '.html'; 我们应该做到这一点。使用mt_rand()代替rand()以获得更好的随机性 <?php $min=1; $max=5; $x =rand($min,$max); $filename

我想随机选择在侧面板中使用的html 我需要一个php调用来用随机文件名填充变量

文件名为Righname_x.html,其中x是随机数(应介于1-5之间)

如何生成要存储在变量中的文件名

$filename = 'rightname_' . mt_rand(1,5) . '.html';
我们应该做到这一点。使用mt_rand()代替rand()以获得更好的随机性


<?php
  $min=1;
  $max=5;
  $x =rand($min,$max);
  $filename = 'Righname_'.$x.'.html';
?>

我请求帮助,因为我不懂php,只需要这个电话。如何将文件名与该函数连接?$filename是包含文件名的变量。我只能猜测当前代码中使用的变量