PHP rand() 함수
예시
난수 생성:
<?php
echo(rand() . "<br>");
echo(rand() . "<br>");
echo(rand(10,100));
?>
정의 및 사용
rand() 함수는 임의의 정수를 생성합니다.
팁 예: 10에서 100(포함) 사이의 임의의 정수를 원하면 rand(10,100)를 사용하십시오.
팁: PHP 7.1부터 rand() 함수는 mt_rand() 함수의 별칭이었습니다.
통사론
rand();
or
rand(min,max);
매개변수 값
Parameter | Description |
---|---|
min | Optional. Specifies the lowest number to return. Default is 0 |
max | Optional. Specifies the highest number to return. Default is getrandmax() |
기술적 세부 사항
반환 값: | min (또는 0)과 max (또는 getrandmax() 포함) 사이의 임의의 정수 |
---|---|
반환 유형: | 정수 |
PHP 버전: | 4+ |
PHP 변경 로그: | PHP 7.1: rand() 함수는
mt_rand() 의 별칭입니다 . PHP 4.2.0: 난수 생성기가 자동으로 시드됩니다. |
❮ PHP 수학 참조