Sr. PHP Programmer Question: Download Questions PDF
What are the 3 scope levels available in PHP and how would you define them?
Answer:
☛ Private - Visible only in its own class
☛ Public - Visible to any other code accessing the class
☛ Protected - Visible only to classes parent(s) and classes that extend the current class
This is important for any developer to know because it shows an understanding that building applications is more than just being able to write code. One must also have an understanding about privileges and accessibility of that code. There are times protected variables or methods are extremely important, and an understanding of scope is needed to protect the integrity of the data in your application along with provide a clear path through the code.
☛ Public - Visible to any other code accessing the class
☛ Protected - Visible only to classes parent(s) and classes that extend the current class
This is important for any developer to know because it shows an understanding that building applications is more than just being able to write code. One must also have an understanding about privileges and accessibility of that code. There are times protected variables or methods are extremely important, and an understanding of scope is needed to protect the integrity of the data in your application along with provide a clear path through the code.
Download Senior PHP Programmer Interview Questions And Answers
PDF
Previous Question | Next Question |
In a PHP class what are the three visibility keywords of a property or method? | What are the different types of PHP variables? |