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? (The following three variables are protectedprivatepublic in sequence .) ----- What is the default access identifier of a class member?
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.