PHP Fresher Interview Questions and Answers Test 2

PHP Fresher interview questions with answers, faqs test 2 to practice php fresher questions. Here, you may find questions to learn PHP Fresher test on type hinting, php interfaces, classes and interfaces, design patterns, php visibilities,

FAQs: PHP Fresher Test 2

Question: What is a type hinting and what are advantages to use it in PHP?


PHP supports type hinting that allows a function or method to take only one object of a set type or its descendants.

Type hinting improves the maintainability of the PHP code. PHP applications with type hinting are less error-prone and self-documenting (partially).

Question: What is an Interface in PHP?


Interfaces are structures to define functionality that a class must implement. These are like templates to be used by developers without dictating inner workings of functionality.

Question: Does Classes inherit interfaces?


No, classes do not inherit interfaces, however they implement the interfaces.

Question: Does an interface can be used by other interfaces?


Yes, one interface can be derived from another interface, incorporating all functionalities of interface along with new functionalities.

Question: What are advantages to use Interfaces?


Interfaces are beneficial for defining sets of functionalities when method implementation is flexible to implement.

They provide benefits due to polymorphism and type hinting.

A class can implement as many interfaces as it can.

An interface can derive multiple other interfaces.

Question: What are design patterns used in PHP?


Following are the design patterns used by PHP programmers and developers:

Proxy, Facade, Decorator, Factory, Singleton, Multiton, Observer Pattern and Publisher/subscriber

Question: How do we declare member variables and methods with accessibility and visibility constraints?


Three types of visibilities are used in PHP scripts:

public: When a member variable or method is declared public then those can be accessed globally by all PHP scripts.

Question: What is CAPTCHA in PHP?


In PHP, Captcha is implemented with images having some characters/digits on it. One need to type the characters or digits in the text box to submit. This stops automatic submitting by an operation by other programs or a robot.