I want to ask questions about static.

Source: Internet
Author: User
When the younger brother is absent, ask static questions static $ aryarray (); $ ary [] a; print_r ($ ary); die (); static $ aryarray (aaa, bbb ); $ ary [] a; print_r ($ ary); why is the output of this code Array ([0] & gt; aaa [1] & gt; not a bb hacker, ask static questions
Static $ ary = array ();
$ Ary [] = 'a ';
Print_r ($ ary); die ();
Static $ ary = array ('AAA', 'BBB ');
$ Ary [] = 'a ';
Print_r ($ ary );

Why is the output of this code
Array ([0] => aaa [1] => bbb [2] =>)

Will the static statement be executed first? No, right ?!

------ Solution --------------------
Yes, you can think so.
Static is interpreted as an internal function by php and executed before the php program.
Therefore, static variables can have initial values, but the initial values cannot contain variables.

In other words, it may be easier to understand:
Static variables have been assigned a value at the beginning of the program.

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.