Php verification code: for ($ I = 0; & nbsp; $ I & lt; 4; & nbsp; $ I ++) {$ rand. = & nbsp; dechex (rand ();} echo & nbsp; $ rand & nbsp; The Not php verification code is displayed in the browser.
Run the following code:
For ($ I = 0; $ I <4; $ I ++ ){
$ Rand. = dechex (rand (1, 15 ));
}
Echo $ rand
The browser displays:
Notice: Undefined variable: rand in D: \ demo. php on line 68
7d7b
But I put. = if it is changed to =, only one random number is displayed, but no error is reported. how can I display four random numbers? I copied the above code online, why can't I execute it here? Thank you for your help !!
------ Solution --------------------
This is not an error. it is a prompt.
It means that your variable $ rand is used without declaration.
Solution:
1. you can declare the value before use, that is, before.
2. for all the error messages of this line on the bi page, add @ before $ rand, that is, @ $ rand .....
3. set the error prompt level globally, error_reporting (......)
4. add a judgment, isset
I personally suggest the first method...
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