PHP hexadecimal random color generator function example, hexadecimal Generator

Source: Internet
Author: User

PHP hexadecimal random color generator function example, hexadecimal Generator

This example describes the PHP hexadecimal color random generator function. We will share this with you for your reference. The details are as follows:

<? Phpfunction randomColor () {$ str = '#'; for ($ I = 0; $ I <6; $ I ++) {$ randNum = rand (0, 15 ); switch ($ randNum) {case 10: $ randNum = 'a'; break; case 11: $ randNum = 'B'; break; case 12: $ randNum = 'C '; break; case 13: $ randNum = 'D'; break; case 14: $ randNum = 'E'; break; case 15: $ randNum = 'F'; break ;} $ str. = $ randNum;} return $ str;} $ color = randomColor (); echo $ color;?>

Running result: #8ABED4

PS: Here are some related color tools for your reference:

RGB color encoding generator:
Http://tools.jb51.net/color/rgb_color_generator

RGB color query table _ color code table _ English name of the color Daquan:
Http://tools.jb51.net/color/jPicker

Online Web page palette tool:
Http://tools.jb51.net/color/color_picker

Online color selector tool/RGB color query table:
Http://tools.jb51.net/color/colorpicker

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.