[Undefinedvariable] Notice: Undefinedvariable solution

Source: Internet
Author: User
[Undefinedvariable] Notice: Undefinedvariable error prompt: Notice: & nbsp; Undefined & nbsp; variable: & nbsp; yan_zheng_shu & nbsp; in code: $ yan_zheng_shu & nbsp ;. & nbsp; dechex (mt_rand (1, & nbsp; 15); ". ", but the result is normal. [Undefined variable] Notice: Undefined variable
Error message: Notice: Undefined variable: yan_zheng_shu in
Code:
$yan_zheng_shu .= dechex(mt_rand(1, 15));

". =" Indicates an error, but the result is displayed normally. "+ =" indicates that "=" is okay.

What should I do? After php. ini is installed, the error prompt is disabled?

Or should I give it an empty character before ". =?

Or is "@" added before?

Which method is standardized?

Thank you.


------ Solution --------------------

This post was last edited by xuzuning at 09:40:09, January 24 ,.

Assign an initial value to $ yan_zheng_shu.
$ Yan_zheng_shu = '';
$ Yan_zheng_shu. = dechex (mt_rand (1, 15 ));
------ Solution --------------------
PHP does not need to declare variables,
However, an error at the E_NOTICE level will still be generated.

$yan_zheng_shu .= dechex(mt_rand(1, 15));

Equivalent
$yan_zheng_shu = $yan_zheng_shu . dechex(mt_rand(1, 15));

Obviously not defined

It is necessary to develop good habits.
------ Solution --------------------
Do you know the meaning of. =? the value assignment is from right to left, so this section certainly does not define the previous variable.

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.