简体   繁体   English

PHP功能需要帮助

[英]Php Function Help Needed

So I modify the code a bit but its seems like the rand() function isn't working properly why ? 所以我稍微修改了代码,但看起来rand()函数不能正常工作,为什么? Below is my code for that also my whole code link is given below. 下面是我的代码,下面是我的整个代码链接。 Any help would be greatly appreciated. 任何帮助将不胜感激。

<tr>
  <td colspan=2 align=right>
    <font color=red>*</font>Order ID
  </td>
  <td>
    <input type='text' name='name' value='<?php echo rand();?>' disabled>
  </td>
</tr>

http://phpfiddle.org/main/code/zw7-bxp http://phpfiddle.org/main/code/zw7-bxp

I think you are using smarty. 我认为您使用的是聪明人。 Therefore please try using . 因此,请尝试使用。

 {php}echo rand();{/php}

From the php-docs: 从php-docs:

If called without the optional min, max arguments rand() returns a pseudo-random
integer between 0 and getrandmax(). If you want a random number between 5 and 15
(inclusive), for example, use rand(5, 15). 

So better use: 所以更好地使用:

<tr>
    <td colspan=2 align=right>
        <font color=red>*</font>Order ID
    </td>
    <td>
        <input type='text' name='name' value='<?php echo rand(min_value, max value);?>' disabled>
    </td>
</tr>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM