Home>Article>Backend Development> PHP randomly generates verification codes of different colors

PHP randomly generates verification codes of different colors

尚
Original
2019-10-26 15:25:31 3368browse

PHP randomly generates verification codes of different colors

php can use the rand() function to generate random numbers, and then use the generated random numbers in the rgb method to set the color to generate different color verification codes.

'; //通过ASCII码值 得到字符串 echo chr(98),'
'; // php 7.0专有 幂运算 echo 2 ** 3,'
'; //字符连接符. echo 'a'.'b'.'c'."
"; $str=''; $str.="a"; $str.="n"; echo "$str".'
'; //产生随机数 #mt_rand($min.$max); 产生随机数 echo (mt_rand(1000,9999)); echo "
"; $code=""; $code.=''.mt_rand(1,9).''; $code.=''.mt_rand(1,9).''; $code.=''.mt_rand(1,9).''; $code.=''.mt_rand(1,9).''; echo "$code";

Recommended:php server

The above is the detailed content of PHP randomly generates verification codes of different colors. For more information, please follow other related articles on the PHP Chinese website!

php
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn