1. Tell me what Is a Persistent Cookie?

The type of cookie which is stored permanently on the browser. A persistent cookie can be used for tracking long-term information.

2. Tell me do you use Composer? If yes, what benefits have you found in it?

Using Composer is a tool for dependency management. The candidate can declare the libraries your product relies on and Composer will manage the installation and updating of the libraries. The benefit is a consistent way of managing the libraries depended on so less time is spent managing the libraries.

3. Tell me does PHP support multiple inheritance?

No. But class can implement multiple interfaces. Multiple inheritance is partially possible using traits.

4. Do you know what is Polymorphism?

It is the basic principle of OOP. You can define base class (may be abstract) Animals and it can then be extended by other classes like Dog, Cat and take part of the behaviour from the parent class.

5. Tell us can you send an Ajax request to another domain?

It is not possible to send an Ajax request if the protocol or host are different. This is called CORS and is checked by the browser.

6. Explain me what's the difference between unset() and unlink()?

unset() sets a variable to “undefined” while unlink() deletes a file we pass to it from the file system.

7. Tell me will comparison of string "10" and integer 11 work in PHP?

Yes, it will, because PHP is not a typed language and it will try to convert variable types before comparison.

8. Tell us can you extend a Final defined class?

No, you cannot extend a Final defined class. A Final class or method declaration prevents child class or method overriding.

9. Explain me what is the difference between the functions unlink and unset?

Unlink() deletes the given file from the file system. Where unset() makes a variable undefined from memory.

10. Tell me what is Memcache?

Technology that caches objects in memory and the application can get to them really fast. It is the basis in scaling larger PHP application.

11. Tell me what's the difference between the include() and require() functions?

They both include a specific file but on require the process exits with a fatal error if the file can't be included, while include statement may still pass and jump to the next step in the execution.

12. Explain me what's the full form of PHP?

Original form is Personal Home Page. However, according to the PHP manual, it is PHP: Hypertext Preprocessor.

13. List out different types of the hook point in Codeigniter?

Different types of hook point in Codeigniter includes

☛ post_controller_constructor
☛ pre_controller
☛ post_sytem
☛ pre_system
☛ cache_override
☛ display_override
☛ post_controller

14. Explain how can we get the browser properties using PHP?

Simple answer is using $_SERVER['HTTP_USER_AGENT']. Not so simple is that we need to take into account proxy servers and other situations. In total, this information is defined in 3 $_SERVER variables.

15. Explain me in PHP what is the difference between a Class and an Interface?

Interface defines the methods and their parameters. Class can then implement the interface (or multiple interfaces) and needs to define such methods. So interface defines outline and class-specific behaviour.

16. What is routing in Codeigniter?

In CodeIgniter, the way PHP files served is different rather than accessing it directly from the browser. This process is called routing. Routing in CodeIgniter gives you freedom to customize the default URL pattern to use our own URL pattern according to the requirement. So, whenever there is a request made and matches our URL pattern it will automatically direct to the specified controller and function.

17. Tell me how you can extend the class in Codeigniter?

To extend the native input class in CodeIgniter, you have to build a file named application/core/MY_Input.php and declare your class with

Class MY_Input extends CI_Input {

}

18. Tell us what are the __construct() and __destruct() methods in a PHP class?

All objects in PHP have Constructor and Destructor methods built-in. The Constructor method is called immediately after a new instance of the class is being created, and it's used to initialize class properties. The Destructor method takes no parameters.

Understanding these two in PHP means that the candidate knows the very basics of OOP in PHP.

19. Tell me the different types of errors in PHP?

Those are Notices, Warnings and Fatal errors are the types of errors in PHP. Notices represents non-critical errors. Warnings are more serious errors but they do not result in script termination. Fatal errors are critical errors i.e. calling a non-existent function or class. These errors cause the immediate termination of the script.

20. Tell me what are the 3 scope levels available in PHP and how would you define them?

☛ 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 PHP 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.

21. Tell me how you can link images/CSS/JavaScript from a view in code igniter?

In HTML, there is no Codeigniter way, as such it is a PHP server side framework. Just use an absolute path to your resources to link images/CSS/JavaScript from a view in CodeIgniter

/css/styles.css

/js/query.php

/img/news/566.gpg

22. Explain echo vs. print statement?

echo() and print() are functions in PHP, both output strings. Function echo() can take multiple expressions whereas print() cannot. Moreover print() returns true or false based on success or failure whereas echo doesn't.

23. Tell me what are PSRs? Choose 1 and briefly describe it?

PSRs are PHP Standards Recommendations that aim at standardising common aspects of PHP Development.

An example of a PSR is PSR-2, which is a coding style guide.

24. Tell me what are the main error types in PHP and how do they differ?

In PHP there are three main type of errors:

☛ Notices – Simple, non-critical errors that are occurred during the script execution. An example of a Notice would be accessing an undefined variable.

☛ Warnings – more important errors than Notices, however the scripts continue the execution. An example would be include() a file that does not exist.

☛ Fatal – this type of error causes a termination of the script execution when it occurs. An example of a Fatal error would be accessing a property of a non-existent object or require() a non-existent file.

25. Tell me how you can prevent CodeIgniter from CSRF?

There are several ways to protect CodeIgniter from CSRF, one way of doing is to use a hidden field in each form on the website. This hidden field is referred as CSRF token; it is nothing but a random value that alters with each HTTP request sent. As soon as it is inserted in the website forms, it gets saved in the user's session as well. So, when the form is submitted by the users, the website checks whether it is the same as the one saved in the session. If it is same then, the request is legitimate.

26. Tell me why is there a need to configure the URL routes?

Changing the URL routes has some benefits like

☛ From SEO point of view, to make URL SEO friendly and get more user visits
☛ Hide some URL element such as a function name, controller name, etc. from the users for security reasons
☛ Provide different functionality to particular parts of a system

27. Tell me how we can get the number of elements in an array?

The count() function is used to return the number of elements in an array.

Understanding of arrays and array related helper functions is important for any PHP developer.

28. Tell me what does a special set of tags <?=$variable ?> do in PHP?

It will output the content of variable into document.

29. Do you know what are the popular frameworks in PHP?

Most popular are: CakePHP, CodeIgniter, Yii 2, Symfony, Zend Framework etc.

30. What is the PHP split() function?

The PHP split() function splits the string into an array by regular expression.

31. Tell me what does MVC stand for and what does each component do?

MVC stands for Model View Controller.
The controller handles data passed to it by the view and also passes data to the view. It's responsible for interpretation of the data sent by the view and dispersing that data to the appropriate models awaiting results to pass back to the view. Very little, if any business logic should be occurring in the controller.

The model's job is to handle specific tasks related to a specific area of the application or functionality. Models will communicate directly with your database or other storage system and will handle business logic related to the results.

The view is passed data by the controller and is displayed to the user.

Overall, this question is worth knowing as the MVC design pattern has been used a lot in the last few years and is a very good design pattern to know. Even with more advanced flows that go down to repositories and entities, they still are following the same basic idea for the Controller and View. The Model is typically just split out into multiple components to handle specific tasks related to database data, business logic etc. The MVC design pattern helps draw a better understanding of what is being used, as a whole, in the industry.

32. Explain me what are Traits?

Traits are a mechanism that allows you to create reusable code in languages like PHP where multiple inheritance is not supported. A Trait cannot be instantiated on its own.

It's important that a developer knows the powerful features of the language (s)he is working on, and Trait is one of such features.

33. Explain me what is the default URL pattern used in Codeigniter framework?

Codeigniter framework URL has four main components in default URL pattern. First we have the server name and next we have the controller class name followed by controller function name and function parameters at the end. Codeigniter can be accessed using the URL helper.
For example http://servername/controllerName/controllerFunction/parameter1/parameter2.

34. Tell me how you will load or add a model in CodeIgniter?

Within your controller functions, models will typically be loaded; you will use the function

$this->load->model (‘Model_Name');