When PHP creates a verification code, the function of the parameter

Source: Internet
Author: User
What is the function of a parameter when PHP creates a verification code?



$x =rand (1,8) + $imagewidth * $i/4;
$y =rand (1, $imageheight/4);






In this circular statement, what is the function of seeking $num?

Because the imagestring () function works: Adds a number to the image. I think that $num is definitely used to limit the number of digits added to the image,
But change $num=4, $num =15 or other numbers, the image still shows 4 characters.

And I would like to ask weakly weak, through post and get pass parameters, such as login?id=2&value=3, this id,value through
$_post or $_get gets, the value of ID and value is an integer or a character!

Do not want to verify, too troublesome, on the Warrior advice!!! PHP Verification Code $_post[]

Share to:


------Solution--------------------
The first question. Do you try $num=2 or four numbers?
$x calculation means only four digits are displayed

The second question I do not know whether it is a character or an integer expecting an expert to answer, but can be when the word trailing characters can also be used as an integer this is the charm of PHP
------Solution--------------------
The first one to see upstairs.

A second string
------Solution--------------------
Your picture width is fixed ...
------Solution--------------------
$x =rand (1,8) + $imagewidth * $i/4;
It's clear that you can adjust the writing order.
$x = $imagewidth/4 * $i + rand (1,8);
which
$imagewidth/4 Divide the width of the canvas into 4 points
$imagewidth/4 * $i The beginning of the first $i character on the canvas
Rand (1,8) lets the starting position be shifted to several points

When the number of characters exceeds 4, there is no limit, just the calculated position outside the canvas. Painted and painted in white.
------Solution--------------------
reference:
Quote: reference:
$x =rand (1,8) + $imagewidth * $i/4;
Adjust the order of writing is clear
$x = $imagewidth/4 * $i + rand (1,8);
Where:
$imagewidth/4 The width of the canvas is divided into 4 points
$imagewidth/4 * $i The first $i characters on the canvas start position
rand (1,8) to have the starting position shifted to a few points

When the number of characters exceeds 4, there is no limit, just the calculated position outside the canvas. Draw also white draw


seems to be a little understanding, with the question, if you want to generate random code containing letters and numbers, how should be rewritten?
Hope Big Brother

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.