怎样把这些随机文字输入到隐藏表单里?
<?php
function genRandomString($len)
{
$chars = array(
"一",
"二",
"三",
"四",
"五",
'六',
'七',
'八',
'九',
"十"
);
$charsLen = count($chars) - 1;
shuffle($chars);
$output = "";
for ($i=0; $i<$len; $i++)
{
$rand = $chars[mt_rand(0,$charsLen)];
if(stripos($output,$rand)=== false)
{
$output .= $rand;
}else
{
$i--;
}
}
return $output;
}
$str = genRandomString(1);
echo $str;
?>
可以放原整的源码吗> <?
追答一般为了页面的整洁和可读性,不会在html代码中加入过于复杂的php脚本,只会将保存结果的变量在页面输出,或嵌套循环。如果你非要显示的话也可以。
<input type="text" name="string" value="<?php第一个方法行通了可是怎把顶部我的PHP隐藏掉><?
追答#可以将顶部的php重新写入到一个文件中,如:one.php。在form中将其包含就行rand.php
<?php在页面中输出
<?php require 'rand.php'; ?>