What is the default access identifier of a class member?

Source: Internet
Author: User
Tags php book
What is the default access identifier of a class member? PHPcodeclassPerson {var $ name; protected $ id; private $ hidden; public $ username;} What is access control for the $ name class member variable in the above code? (What are the default access identifiers for the third-class members?
PHP code
  Class Person {var $ name; protected $ id; private $ hidden; public $ username ;}

In the above code, what is access control for the $ name class member variable? (The following three variables are protected private public .)


------ Solution --------------------
The default value is pubilc.

However, we recommend that you use public instead of var to develop good habits and adapt to PHP6 in the future.
------ Solution --------------------
If you do not declare it, it is public.
Discussion

Reference:

The default value is pubilc.

However, we recommend that you use public instead of var to develop good habits and adapt to PHP6 in the future.

Oh, is it public if the function does not write the access ID?
I did not read the PHP book, which is confusing. the access control letter in JAVA is different from that in private, public, and protected.

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.